find and solve || findandsolve.com
Please wait.....

C# String.ToLower()

In the C# String.ToLower() method is used to get a copy of a given string converted to all lowercase. This method does not modify the original string only convert uppercase to lowercase.

In this tutorial, you will learn about the syntax of C# String.ToLower() and C# String.ToLower(CultureInfo) methods, and learn how to use these method in c# language with good examples.

String.ToLower() Method

This method is used to return a copy of the current string converted to lowercase.

Syntax
String.ToLower()

Return Type: It return the string value, which is the lowercase equivalent of the string of type System.String.

ToLower() Example

In this example, I will take a string with some upper-case and some lower-case alphabets, say "Find And Solve". To get lower-case of this string we will call ToLower() method on this string. A string with all the lower case characters for the given string should be returned by ToLower() method

using System;
public class Program {
    // Main Method
    public static void Main()
    {
        String str = "Find And Solve";
        String result = str.ToLower();
        Console.WriteLine("Original String is : {0}",str);
        Console.WriteLine("Result of ToLower() : {0}",str);
  }
}

Output

Original String is : Find And Solve

Result of ToLower() : Find And Solve


String.ToLower(CultureInfo) Method

This method is used to return a copy of the current string converted to lowercase, using the casing rules of the specified culture.

Syntax:

public string ToLower (System.Globalization.CultureInfo culture);
  • Return Type: This method returns the lowercase equivalent of the current string of type System.String.
  • Exception: This method can give ArgumentNullException if the value of culture is null.
using System;
using System.Globalization;
public class Program {
    // Main Method
    public static void Main()
    {
        // original string
        string str = "FIND AND SOLVE";
        // string converted to lowercase by
        // using English-United States culture
        string lowerstr = str.ToLower(new CultureInfo("en-US", false));
        Console.WriteLine(lowerstr);
  }
}

Output

find and solve