I have this class :
public class MyClass
{
public MyClass()
{
}
public int value { get; set; }
}
and I add 3 of this class on a List :
MyClass class1 = new MyClass()
MyClass class2 = new MyClass()
MyClass class3 = new MyClass()
IList<MyClass> classList = new List<MyClass>().ToList();
classList.Add(class1);
classList.Add(class2);
classList.Add(class3);
Now, I’d like to order this list (ascending) according to the MyClass.value value.
How can I do it on C#?
IList is not mandatory, so if you know any other strategies to order this would be good.
Just do this after you add all items to classList. ( This works in Framwork 3.5sp1 or later)