LINQ-uses of orderby to sort a list of words alphabetically.

This Function show you how to use orderby to sort a list of word alphabetically.

         public void OrderByExample()
        {

            string[] words = { "India", "England", "America","China","Australia" };

            var sortedWords =
                from w in words
                orderby w
                select w;

            Console.WriteLine("The sorted list of words:");
            foreach (var w in sortedWords)
            {
                Console.WriteLine(w);
            }

        }

Ebook Download
View all
Learn
View all