Partager via


String.ToLower Method

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

Returns a copy of this string converted to lowercase, using the casing rules of the current culture.

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

Syntax

'Declaration
Public Function ToLower As String
public string ToLower()

Return Value

Type: System.String
The lowercase equivalent of the current string.

Remarks

Starting in Silverlight 4, the behavior of the String.ToLower() method has changed. In Silverlight 4, it converts the current string instance to lowercase using the casing rules of the current culture. This conforms to the behavior of the String.ToLower() method in the full .NET Framework. In Silverlight 2 and Silverlight 3, it uses the casing rules of the invariant culture.

NoteNote:

This method does not modify the value of the current instance. Instead, it returns a new string in which all characters in the current instance are lowercased.

Examples

The following code example converts several mixed case strings to lowercase.


Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim info As String() = {"Name", "Title", "Age", "Location", "Gender"}

      outputBlock.Text &= "The initial values in the array are:" & vbCrLf

      Dim s As String
      For Each s In info
         outputBlock.Text &= s & vbCrLf
      Next s

      outputBlock.Text &= String.Format("{0}The lowercase of these values is:", vbCrLf) & vbCrLf

      For Each s In info
         outputBlock.Text &= s.ToLower() & vbCrLf
      Next s

      outputBlock.Text &= String.Format("{0}The uppercase of these values is:", vbCrLf) & vbCrLf

      For Each s In info
         outputBlock.Text &= s.ToUpper() & vbCrLf
      Next s
   End Sub 'Main
End Class 'ToLowerTest
using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {

      string[] info = { "Name", "Title", "Age", "Location", "Gender" };

      outputBlock.Text += "The initial values in the array are:" + "\n";
      foreach (string s in info)
         outputBlock.Text += s + "\n";

      outputBlock.Text += String.Format("{0}The lowercase of these values is:", "\n") + "\n";

      foreach (string s in info)
         outputBlock.Text += s.ToLower() + "\n";

      outputBlock.Text += String.Format("{0}The uppercase of these values is:", "\n") + "\n";

      foreach (string s in info)
         outputBlock.Text += s.ToUpper() + "\n";
   }
}

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.