How to remove duplicate values from an array in C#

1 Answer

0 votes
using System;
using System.Linq;

class Program
{
    static void Main() {
        string[] arr = { "c", "c++", "c#", "c", "java", "java", "c", "python", "c++" };
        
		arr = arr.Distinct().ToArray();
		
		Array.ForEach(arr, s => Console.WriteLine(s));
    }
}




/*
run:
  
c
c++
c#
java
python
  
*/

 



answered Aug 12, 2021 by avibootz

Related questions

...