Convert All Strings in a List to Upper Case using LINQ in C#

Below is a sample code snippet which demonstrates on how to convert all strings in a list to upper case using LINQ in C#.

Convert All Strings in a List to Upper Case using LINQ in C#

using System;
using System.Collections.Generic;
using System.Linq;

namespace AbundantCode
{
    internal class Program
    {
        //Convert All Strings in a List to Upper Case using LINQ in C#
        private static void Main(string[] args)

        {
            List<string> Names = new List<string>();

            Names.Add("Abundantcode");

            Names.Add("Programming");

            Names.Add("Websites");

            Names.Add("Coding");

            Names.Add("Technologies");

            Names.Add("USA");

            Names.Add("C#");

            Names.Add(".NET");

            var result = Names.Select(m => m.ToUpper());

            foreach (var item in result)

                Console.WriteLine(item);

            Console.ReadLine();
        }
    }
}

Output

1 Comment

Leave Your Comment

Liked this content?. Please spread the word :)