Count - Simple

Query
public void Linq73()
{
int[] factorsOf300 = { 2, 2, 3, 5, 5 };

int uniqueFactors = factorsOf300.Distinct().Count();

Console.WriteLine("There are {0} unique factors of 300.", uniqueFactors);
}
Lambda Expression
public void Linq73()
{
int[] primeFactorsOf300 = { 2, 2, 3, 5, 5 };

int uniqueFactors = primeFactorsOf300.Distinct().Count();

Console.WriteLine("There are {0} unique prime factors of 300.", uniqueFactors);
}
Output
There are 3 unique factors of 300.
Related Tutorial