Uniqe Array
-
Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran
-
Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran
Have a look at the free PowerCollections library. http://www.wintellect.com/[^] You have to register to access it but registration is free and you won't get spammed! :) Oh, I'm assuming you're using .NET 2.0? Kevin
-
Hello, Is not there any method available to make an Array with only Unique elements in C# ? after calling the method, the Array must get rid of all duplicate elements. Thanks Emran
OK, I've found an example I wrote a while back using the PowerCollections library.
int[] source = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; List list = new List(source); list.Sort(); Algorithms.RemoveDuplicatesInPlace(list); foreach (int var in list) { Console.WriteLine(var); }
Kevin -
OK, I've found an example I wrote a while back using the PowerCollections library.
int[] source = { 1, 4, 4, 6, 1, 2, 2, 3, 1, 6, 6, 6, 5, 7, 5, 4, 4 }; List list = new List(source); list.Sort(); Algorithms.RemoveDuplicatesInPlace(list); foreach (int var in list) { Console.WriteLine(var); }
Kevin -
Have a look at the free PowerCollections library. http://www.wintellect.com/[^] You have to register to access it but registration is free and you won't get spammed! :) Oh, I'm assuming you're using .NET 2.0? Kevin
-
Hello Kevin,. Thanks for your reply. Ok, would this remove duplicate with case insensitive or case sensitive. ? Emran
I'm away from my development PC for a couple of days. But generally these methods allow you to define a function (called a "predicate" in this context) which allows you to define the criterion for a match. Just download that library and investigate. It comes with a sample solution which demonstrates most or all of the algorithms. And re: your other reply, PowerCollections works with .NET 2.0 only, so it should work for you. There's no installation program. You just unzip the download and add a reference to the DLL. But, as I said, you do have to register at the Wintellect site (for free) to get it. When it just came out, anyone could access it. I don't know whether you've done any C++, but PowerCollections is similar in philosophy, and has similar algorithms, to the STL. Kevin