Introduction
This code snippet is Remove duplicate values in an array using C# & Linq
Code
- using System;
- using System.Linq;
- public class Program
- {
- public static void Main()
- {
- int[] array = {1, 4, 2, 8, 7,9,12,65,88,43,88,33,12,98,65};
- //Remove duplicate value using Distinct method in Linq
- var RemoveDuplicateValue = array.Distinct();
- foreach (int value in RemoveDuplicateValue)
- {
- Console.Write(value + " ");
- }
- }
- }
1 4 2 8 7 9 12 65 88 43 33 98
Demo : https://dotnetfiddle.net/Vb7kZ4
