Condividi tramite


TextInfo.ToLower Method (Char)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Converts the specified character to lowercase.

Namespace:  System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Overridable Function ToLower ( _
    c As Char _
) As Char
[SecuritySafeCriticalAttribute]
public virtual char ToLower(
    char c
)

Parameters

  • c
    Type: System.Char
    The character to convert to lowercase.

Return Value

Type: System.Char
The specified character converted to lowercase.

Remarks

Casing semantics depend on the culture in use. For the invariant culture, the casing semantics are not culture-sensitive. For a specific culture, the casing semantics are sensitive to that culture.

If a security decision depends on a string comparison or a case-change operation, the application should use the CultureInfo.InvariantCulture to ensure that the behavior is consistent regardless of the culture settings of the system. However, the invariant culture must be used only by processes that require culture-independent results, such as system services. Otherwise, it produces results that might be linguistically incorrect or culturally inappropriate.

For more information on cultures, see CultureInfo.

Examples

The following code example changes the casing of a string based on the "en-US" culture.

Imports System.Globalization

Public Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      ' 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").TextInfo

      ' Changes a string to lowercase.
      outputBlock.Text += String.Format("""{0}"" to lowercase: {1}", myString, myTI.ToLower(myString)) & vbCrLf

      ' Changes a string to uppercase.
      outputBlock.Text += String.Format("""{0}"" to uppercase: {1}", myString, myTI.ToUpper(myString)) & vbCrLf
   End Sub 
End Class 
' This example produces the following output.
'       "wAr aNd pEaCe" to lowercase: war and peace
'       "wAr aNd pEaCe" to uppercase: WAR AND PEACE
using System;
using System.Globalization;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      // 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").TextInfo;

      // Changes a string to lowercase.
      outputBlock.Text += String.Format("\"{0}\" to lowercase: {1}", myString, myTI.ToLower(myString)) + "\n";

      // Changes a string to uppercase.
      outputBlock.Text += String.Format("\"{0}\" to uppercase: {1}", myString, myTI.ToUpper(myString)) + "\n";
   }
}
/*
This example produces the following output.
      "wAr aNd pEaCe" to lowercase: war and peace
      "wAr aNd pEaCe" to uppercase: WAR AND PEACE
*/

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.