.ToLower()
The .ToLower()
method is a string method in C# that returns a new string in which all the characters are converted to lowercase.
The method does not modify the original string, but rather returns a new one. This method is helpful in normalizing user input or comparing strings in a case-insensitive manner.
Syntax
myString.ToLower();
myString
is the string being converted to lowercase.
Example
In the following example, the .ToLower()
method is called on a string originalString
, and is printed to the console:
using System;string originalString = "HELLO WORLD";Console.WriteLine(originalString.ToLower()); // Output: "hello world"
Codebyte Example
In following runnable example, a new string originalString
is created that contains some text. Then, the .ToLower()
method is called on this string and the result is stored in a new string variable lowerCaseString
. Finally, both the original and the lowercase strings are printed to the console.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C# on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C#
Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.Beginner Friendly23 hours