c# - to sort a collection that I do not know what type does it have? -
Is there a way. I can sort my collection in .NET when I do not know how the objects in run-time I
Any thoughts? You need to find some ways to compare elements: Generally ask for ICOMperbal:
class MyCollection & lt; T & gt; Where T: Icom Parabal & lt; T & gt; {}
or use IComparer, either for the sorting method or the constructor:
class MyCollection & lt; T & gt; // where T: icomperbal & lt; T & gt; {Zero Sorted (ICMPear Comparator) {If (comparer.Compare (a, b)> 0) {...}}}
Comments
Post a Comment