Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In .NET Framework 4.0 we have a new class called SortedSet<T>. This helps us to sort the elements without explicitly we implementing any sort method.
var sSet = new SortedSet<int> { 2, 4, 6, 8, 9, 1, 3, 5, 7 };
//Getting directly the sorted output
foreach (int iVal in sSet)
{
Console.WriteLine(iVal);
}
This would give you output in the following order,
1
2
3
4
5
6
7
8
9
Also we can get Min and Max
//Min & Max
Console.WriteLine("Max = {0}", sSet.Max);
Console.WriteLine("Min = {0}", sSet.Min);
This could be helpful wherever we predict to call a Sort function while working with the collection.
Namoskar!!!
Comments
- Anonymous
January 12, 2015
I can use hashset from powershell, using the generics collection, but not the sortedset. Any suggestions?