I would like to know how to write a Linq (using lambda Expression in standard dot notation) query. I have an array of some names, and I would like to retrevie a new array of names based on one statement. This is: Order the array of names, and return a new list from the name which starts on some specific letter (lets say letter M) on.
This is my current array:
string[] arrNames = { "Mike", "Zach", "Ella", "Allan", "Jo", "Roger", "Tito" };
I would like to return names like this: Mike, Roger, Tito, Zach - these 4; Other 3 names (Allan, Ella and Jo are names which start with a letter that are in the alphabetica order bellow letter "M". This is not the same as using Operator "StartsWith". This one only selects the names started on the specific letter. I would like to get all the names which are in alphabetical order from this letter and on (so names started from M to Z).
So retun list with names starts with letter "M" or above looking on the alphabetical order.
Mitja
var result = arrNames.Where(i => String.Compare("M", i) <= 0)
.OrderBy(i => i);
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