Say I've got this array: MyArray(0)="aaa" MyArray(1)="bbb" MyArray(2)="aaa"
Is there a .net function which can give me the unique values? I would like something like this as an output of the function: OutputArray(0)="aaa" OutputArray(1)="bbb"
Using Python's import numpy, the unique elements in the array are also obtained. In the first step convert the list to x=numpy. array(list) and then use numpy. unique(x) function to get the unique values from the list.
Calculate the length of an array using the length() function that will return an integer value as per the elements in an array. Call the sort function and pass the array and the size of an array as a parameter. Take a temporary variable that will store the count of distinct elements. Print the result.
All(x => values. Count(y => x == y) == 1); If the result of any of these expressions is false, that means your array has duplicates, otherwise all elements are unique. Save this answer.
Assuming you have .Net 3.5/LINQ:
string[] OutputArray = MyArray.Distinct().ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With