Distinct Operator : Distinct : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Distinct »

 

Distinct Operator








    
 
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass {
    public static void Main() {
        string[] presidents = {"Grant", "Harding", "Harrison", "Hayes", "Hoover", "Jackson"};
        Console.WriteLine("presidents count:  " + presidents.Count());
        IEnumerable<string> presidentsWithDupes = presidents.Concat(presidents);
        Console.WriteLine("presidentsWithDupes count:  " + presidentsWithDupes.Count());
        IEnumerable<string> presidentsDistinct = presidentsWithDupes.Distinct();
        Console.WriteLine("presidentsDistinct count:  " + presidentsDistinct.Count());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Distinct