R
raylopez99
See the // commented out lines below.
This is what I want a query for (in lambda notation).
Basically to order an array of ints from lowest value to highest value
(ascending). I can do this with LINQ, but how to do it with lambda
notation?
RL
int [] intArr = new int[5]{1,22,3,11,14};
IEnumerable<int> myfilteredInts = from n in intArr
where n > 10
select n;
foreach (int i in myfilteredInts)
{ Console.Write("filteredInt: {0} ,", i); }
Console.WriteLine("");
var reverseInts = myfilteredInts.Reverse(); //reverse the
natural sequence
foreach (int i in reverseInts)
{ Console.Write("reverseInts: {0} ,r,", i); }
var orderHighToLow = from n in reverseInts
orderby n descending
select n;
Console.WriteLine("HightoLow");
foreach (int i in orderHighToLow)
{ Console.Write("ordrH->L {0} ,Hl,", i); }
Console.WriteLine("LowtoHigh");
//var orderLowToHigh = from m in orderHighToLow
// orderby m ascending
// select m;
//foreach (int i in orderLowToHigh)
//{ Console.Write("ordrL>>H {0} ,lH,", i); } ////works fine
This is what I want a query for (in lambda notation).
Basically to order an array of ints from lowest value to highest value
(ascending). I can do this with LINQ, but how to do it with lambda
notation?
RL
int [] intArr = new int[5]{1,22,3,11,14};
IEnumerable<int> myfilteredInts = from n in intArr
where n > 10
select n;
foreach (int i in myfilteredInts)
{ Console.Write("filteredInt: {0} ,", i); }
Console.WriteLine("");
var reverseInts = myfilteredInts.Reverse(); //reverse the
natural sequence
foreach (int i in reverseInts)
{ Console.Write("reverseInts: {0} ,r,", i); }
var orderHighToLow = from n in reverseInts
orderby n descending
select n;
Console.WriteLine("HightoLow");
foreach (int i in orderHighToLow)
{ Console.Write("ordrH->L {0} ,Hl,", i); }
Console.WriteLine("LowtoHigh");
//var orderLowToHigh = from m in orderHighToLow
// orderby m ascending
// select m;
//foreach (int i in orderLowToHigh)
//{ Console.Write("ordrL>>H {0} ,lH,", i); } ////works fine