Consider the following code
- var numbers = new int[] { 1, 4, 6, 2, 9, 10, 0, 99, 33 };
- var sortedNums = from n in numbers
- orderby n descending
- select n;
- foreach (var v in sortedNums)
- Console.WriteLine(v);
- var sports = new string[] { "soccer", "baseball" };
- var Name = from sport in sports select new { Title = sport };
- foreach (var s in Name)
- Console.WriteLine(s.Title);
Line 3 sorts the array of anonymous numbers in descending order ( by default ASC is used )
Line 10 gives a new property to the the string collection created in line 9, see the new property usage in Line 12
Comments