C# String ToLower()

The String ToLower() method converts all characters in the string to lowercase.

Example

using System;  
namespace CsharpString {  
  class Test {
    public static void Main(string [] args) {
     
      string str = "CHOCOLATE";
     
// converts str to lowercase string result = str.ToLower();
Console.WriteLine(result); Console.ReadLine(); } } } // Output: chocolate

ToLower() Syntax

The syntax of the string ToLower() method is:

ToLower()

Here, ToLower() is a method of class String.


ToLower() Return Value

The ToLower() method returns:

  • copy of the string after converting it to lowercase

Example 1: C# String ToLower()

using System;  
namespace CsharpString {  
  class Test {
    public static void Main(string [] args) {
     
      string str = "ICE CREAM";
     
// converts str to lowercase string result = str.ToLower();
Console.WriteLine(result); Console.ReadLine(); } } }

Output

ICE CREAM

ToLower() With CultureInfo Parameter

We can also pass CultureInfo as an argument to the ToLower() method. CultureInfo allows us to use the casing rules of the specified culture.

Its syntax is:

ToLower(System.Globalization.CultureInfo culture)

Here, culture supplies culture-specific casing rules.


Example 2: C# String ToLower() With CultureInfo

using System;  
using System.Globalization;
namespace CsharpString {  
  class Test {
    public static void Main(string [] args) {
     
      string str = "ICE CREAM";
     
// converts str to lowercase in Turkish-Turkey culture string result = str.ToLower(new CultureInfo("tr-TR", false));
Console.WriteLine(result); Console.ReadLine(); } } }

Output

ıce cream

In the above program, notice the following code:

str.ToLower(new CultureInfo("tr-TR", false))

Here, we have used the casing of Turkish-Turkey culture on str. This is given by the following CultureInfo() parameters:

  • tr-TR - uses Turkish-Turkey culture
  • false - denotes default culture settings

As a result, the uppercase "I" is converted to the Turkish "ı" instead of the US-English "i".

Did you find this article helpful?