Linq Query:
Output:
Now Descending Order by :
Output:
//Order By string[] alphabets = { "h", "b", "m", "q", "v", "p", "a", "c" }; //ascending var sorted = from s in alphabets orderby s //by default ascending select s; foreach (var t in sorted) { Console.WriteLine(t.ToString()); }
Output:
a
b
c
h
m
p
q
v
Now Descending Order by :
//desending var dsorted = from s in alphabets orderby s descending select s; foreach (var t in dsorted) { Console.WriteLine(t.ToString()); }
Output:
v
q
p
m
h
c
b
a
0 comments:
Post a Comment