How to delete all duplicate elements from int array in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        int[] arr = {1, 8, 8, 8, 5, 12, 18, 19, 12, 12, 100, 8, 133};
        
        arr = arr.Distinct().ToArray();

        Console.WriteLine(string.Join(" ", arr));
    }
}



/*
run:

1 8 5 12 18 19 100 133

*/

 



answered Jul 24, 2020 by avibootz
...