LINQ Distinct Method (C#.net):
The following code shows you how to remove reapeating elements from your array, i.e, if your array contains 2 , 1 , 3 , 2 , 5, now you want remove 2 which comes two times in your array. after applying Distinct() method the output would be like that 2 , 1 , 3 , 5. See the code below.
Code
int[] arr1 = { 2, 1, 2, 3, 7, 5, 10, 9 };
var query = arr1.Distinct();
foreach (var item in query)
Console.Write(item + " ");
2 1 3 7 5 10 9
0 comments:
Post a Comment