I have one HashSet, and when I use the Addcollection method nothing is added. The output is still 2, 3, 5, 7, 11, 13, and the output from .Countis 6.
Is this a mistake or am I doing something wrong here?
namespace AllerDiz
{
class MainClass
{
public static void Main (string[] args)
{
HashSet<int> smallPrimeNumbers = new HashSet<int> { 2, 3, 5, 7, 11, 13 };
smallPrimeNumbers.Add (3);
smallPrimeNumbers.Add (5);
smallPrimeNumbers.Add (7);
Console.WriteLine ("{0}", smallPrimeNumbers.Count);
foreach(int val in smallPrimeNumbers)
{
Console.WriteLine ("HashSet Value= {0}", val);
}
}
}
}
source
share