LINQ query in C#


This example uses a foreach-loop that evaluates a LINQ expression. The expression sorts an array. The LINQ extension provides queries that are evaluated lazily. The sorting in the example won't occur until the foreach-loop is executed.




string[] name = {"c","d","b","a" };
            var stor = from str in name orderby str select str;
            foreach(string value in stor)
            {
                Console.WriteLine(value);
            }