I have a for loop where i want to orderby the name alphabetically
a
b
c
d
looking how to do this, wondered even if i could use linq orderby inside the forloop?
Try this:
List<Item> myItems = new List<Item>();
//load myitems
foreach(Item i in myItems.OrderBy(t=>t.name))
{
//Whatever
}
You don't need a Loop at all. Just use LINQ:
List<MyClass> aList = new List<MyClass>();
// add data to aList
aList.OrderBy(x=>x.MyStringProperty);
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