I am having trouble with the LINQ query I am supposed to be using.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LinqIntegersDemo.cs
{
class Program
{
static void Main(string[] args)
{
int[] nums = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// var sorted = from n in nums orderby n ascending select n;
int x = 0;
foreach (var n in nums)
{
Console.Write("Enter an integer >> ");
nums[x] = Convert.ToInt32(Console.ReadLine());
++x;
}
var sorted = from n in nums orderby n ascending select n;
foreach (var n in nums)
{
Console.WriteLine(n);
}
Console.ReadLine();
}
}
}
I have looked through MSDN and the snippets I have seen there told me that I wrote my query correctly. So why is it that the array is not being sorted in ascending order, which is what I need to happen.