EN
C# / .NET - lowercase all List elements
0
points
In this article, we would like to show you how to lowercase all List elements in C#.
Quick solution:
List<string> myList = new List<string> { "A", "B", "C" };
myList = myList.Select(x => x.ToLower()).ToList();
Practical example
In this example, we select all items from myList and lowercase them using ToLower() method.
using System;
using System.Linq;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<string> myList = new List<string> { "A", "B", "C" };
// lowercase all elements
myList = myList.Select(x => x.ToLower()).ToList();
// display result
myList.ForEach(x => Console.WriteLine(x));
}
}
Output:
a
b
c