Export (0) Print
Expand All

TextInfo.ToLower Method

Converts the specified character or string to lowercase.

Overload List

Converts the specified character to lowercase.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Function ToLower(Char) As Char
[C#] public virtual char ToLower(char);
[C++] public: virtual __wchar_t ToLower(__wchar_t);
[JScript] public function ToLower(Char) : Char;

Converts the specified string to lowercase.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Overridable Function ToLower(String) As String
[C#] public virtual string ToLower(string);
[C++] public: virtual String* ToLower(String*);
[JScript] public function ToLower(String) : String;

Example

[Visual Basic, C#, C++] The following code example changes the casing of a string based on the "en-US" culture.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of ToLower. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System
Imports System.Globalization

Public Class SamplesTextInfo

   Public Shared Sub Main()

      ' Defines the string with mixed casing.
      Dim myString As String = "wAr aNd pEaCe"

      ' Creates a TextInfo based on the "en-US" culture.
      Dim myTI As TextInfo = New CultureInfo("en-US", False).TextInfo

      ' Changes a string to lowercase.
      Console.WriteLine("""{0}"" to lowercase: {1}", myString, myTI.ToLower(myString))

      ' Changes a string to uppercase.
      Console.WriteLine("""{0}"" to uppercase: {1}", myString, myTI.ToUpper(myString))

      ' Changes a string to titlecase.
      Console.WriteLine("""{0}"" to titlecase: {1}", myString, myTI.ToTitleCase(myString))

   End Sub 'Main 

End Class 'SamplesTextInfo


'This code produces the following output.
'
'"wAr aNd pEaCe" to lowercase: war and peace
'"wAr aNd pEaCe" to uppercase: WAR AND PEACE
'"wAr aNd pEaCe" to titlecase: War And Peace



[C#] 
using System;
using System.Globalization;


public class SamplesTextInfo  {

   public static void Main()  {

      // Defines the string with mixed casing.
      string myString = "wAr aNd pEaCe";

      // Creates a TextInfo based on the "en-US" culture.
      TextInfo myTI = new CultureInfo("en-US",false).TextInfo;

      // Changes a string to lowercase.
      Console.WriteLine( "\"{0}\" to lowercase: {1}", myString, myTI.ToLower( myString ) );

      // Changes a string to uppercase.
      Console.WriteLine( "\"{0}\" to uppercase: {1}", myString, myTI.ToUpper( myString ) );

      // Changes a string to titlecase.
      Console.WriteLine( "\"{0}\" to titlecase: {1}", myString, myTI.ToTitleCase( myString ) );

   }

}

/*
This code produces the following output.

"wAr aNd pEaCe" to lowercase: war and peace
"wAr aNd pEaCe" to uppercase: WAR AND PEACE
"wAr aNd pEaCe" to titlecase: War And Peace

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

int main()
{
   // Defines the String* with mixed casing.
   String* myString = S"wAr aNd pEaCe";

   // Creates a TextInfo based on the S"en-US" culture.
   CultureInfo * MyCI = new CultureInfo(S"en-US", false);
   TextInfo* myTI = MyCI -> TextInfo;

   // Changes a String* to lowercase.
   Console::WriteLine(S"\"{0}\" to lowercase: {1}", myString, myTI -> ToLower(myString));

   // Changes a String* to uppercase.
   Console::WriteLine(S"\"{0}\" to uppercase: {1}", myString, myTI -> ToUpper(myString));

   // Changes a String* to titlecase.
   Console::WriteLine(S"\"{0}\" to titlecase: {1}", myString, myTI -> ToTitleCase(myString));
}

/*
This code produces the following output.

S"wAr aNd pEaCe" to lowercase: war and peace
S"wAr aNd pEaCe" to uppercase: WAR AND PEACE
S"wAr aNd pEaCe" to titlecase: War And Peace

*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

TextInfo Class | TextInfo Members | System.Globalization Namespace

Show:
© 2015 Microsoft