int values = {1,2,3,3,4,5,6,6}; HashSet<int> set = new HashSet<int>(); foreach(int i in values) {set.Add(i);} Console.WriteLine(set.Count)