語言

TextInfo.ToLower 方法

定義

將指定的字元或字串轉換為小寫。

多載

名稱 Description
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)

來源:
TextInfo.cs
來源:
TextInfo.cs
來源:
TextInfo.cs
來源:
TextInfo.cs
來源:
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)

來源:
TextInfo.cs
來源:
TextInfo.cs
來源:
TextInfo.cs
來源:
TextInfo.cs
來源:
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)

來源:
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

傳回

適用於