TextInfo.ToLower 方法

定义

将指定的字符或字符串转换为小写。

重载

名称 说明
ToLower(Char)

将指定的字符转换为小写。

ToLower(String)

将指定的字符串转换为小写。

ToLower(Rune)

示例

下面的代码示例使用区域性名称 en-US更改基于英语(美国)区域性的字符串的大小写。

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

*/
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

End Class


'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

ToLower(Char)

Source:
TextInfo.cs
Source:
TextInfo.cs
Source:
TextInfo.cs
Source:
TextInfo.cs
Source:
TextInfo.cs

将指定的字符转换为小写。

public:
 virtual char ToLower(char c);
public:
 char ToLower(char c);
public virtual char ToLower(char c);
public char ToLower(char c);
abstract member ToLower : char -> char
override this.ToLower : char -> char
member this.ToLower : char -> char
Public Overridable Function ToLower (c As Char) As Char
Public Function ToLower (c As Char) As Char

参数

c
Char

要转换为小写的字符。

返回

转换为小写的指定字符。

注解

大小写语义取决于正在使用的区域性。 对于固定区域性,大小写语义不区分区域性。 对于特定区域性,大小写语义对该区域性敏感。

如果安全决策取决于字符串比较或大小写更改操作,则应用程序应使用该 InvariantCulture 决策来确保无论系统的区域性设置如何,行为都是一致的。 但是,固定区域性只能由需要与区域性无关的结果(如系统服务)的进程使用。 否则,它会产生语言错误或文化不适当的结果。

有关区域性的详细信息,请参阅 CultureInfo

另请参阅

适用于

ToLower(String)

Source:
TextInfo.cs
Source:
TextInfo.cs
Source:
TextInfo.cs
Source:
TextInfo.cs
Source:
TextInfo.cs

将指定的字符串转换为小写。

public:
 virtual System::String ^ ToLower(System::String ^ str);
public:
 System::String ^ ToLower(System::String ^ str);
public virtual string ToLower(string str);
public string ToLower(string str);
abstract member ToLower : string -> string
override this.ToLower : string -> string
member this.ToLower : string -> string
Public Overridable Function ToLower (str As String) As String
Public Function ToLower (str As String) As String

参数

str
String

要转换为小写的字符串。

返回

转换为小写的指定字符串。

例外

str 为 null。

注解

返回的字符串长度可能与输入字符串不同。 有关大小写的详细信息,请参阅 Unicode 联盟发布的 Unicode 技术报告 #21“案例映射”。 当前实现保留字符串的长度。 但是,此行为是不能保证的,将来的实现可能会更改。

大小写语义取决于正在使用的区域性。 对于固定区域性,大小写语义不区分区域性。 对于特定区域性,大小写语义对该区域性敏感。

如果安全决策取决于字符串比较或大小写更改操作,则应用程序应使用该 InvariantCulture 决策来确保无论系统的区域性设置如何,行为都是一致的。 但是,固定区域性只能由需要与区域性无关的结果(如系统服务)的进程使用。 否则,它会产生语言错误或文化不适当的结果。

有关区域性的详细信息,请参阅 CultureInfo

另请参阅

适用于

ToLower(Rune)

Source:
TextInfo.cs
public:
 System::Text::Rune ToLower(System::Text::Rune value);
public System.Text.Rune ToLower(System.Text.Rune value);
member this.ToLower : System.Text.Rune -> System.Text.Rune
Public Function ToLower (value As Rune) As Rune

参数

value
Rune

返回

适用于