C# String - ToLower() Method
The C# ToLower() method returns the string with all characters of the specified string in lowercase. Any symbol, space, special character or number in the string is ignored while applying this method. Only Alphabets are converted.
Note: This method can be overloaded by passing different type of arguments to it.
Syntax
public string ToLower(); public string ToLower (System.Globalization.CultureInfo culture);
Parameters
culture |
Specify an object that supplies culture-specific casing rules. |
Return Value
Returns the string with all characters of the specified string in lowercase.
Exception
Throws ArgumentNullException, if the culture is null.
Example:
In the example below, ToLower() method returns a string containing all characters of the specified string MyStr in lowercase.
using System; class MyProgram { static void Main(string[] args) { string MyStr = "HeLLo John!"; string NewStr = MyStr.ToLower(); Console.WriteLine(NewStr); } }
The output of the above code will be:
hello john!
Example:
In the example below, ToLower() method returns a string containing all characters of the specified string MyStr in lowercase using the English-United States and Turkish-Turkey cultures.
using System; using System.Globalization; class MyProgram { static void Main(string[] args) { string MyStr = "HeLLo John!"; string NewStr1 = MyStr.ToLower(new CultureInfo("en-US", false)); string NewStr2 = MyStr.ToLower(new CultureInfo("tr-TR", false)); Console.WriteLine(NewStr1); Console.WriteLine(NewStr2); } }
The output of the above code will be:
hello john! hello john!
❮ C# String Methods