Set Operators: Distinct

image_pdfimage_print
   
 

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

public class MainClass {
    public static void Main() {

        int[] fl = { 2, 2, 3, 5, 5 };

        var uniqueFactors = fl.Distinct();

        Console.WriteLine("Prime factors of 300:");
        foreach (var f in uniqueFactors) {
            Console.WriteLine(f);
        }
    }
}

    


This entry was posted in LINQ. Bookmark the permalink.