Char.GetUnicodeCategory Char.GetUnicodeCategory Char.GetUnicodeCategory Char.GetUnicodeCategory Method

定義

將 Unicode 字元分類至由其中一個 UnicodeCategory 值所識別的群組。Categorizes a Unicode character into a group identified by one of the UnicodeCategory values.

多載

GetUnicodeCategory(Char) GetUnicodeCategory(Char) GetUnicodeCategory(Char) GetUnicodeCategory(Char)

將指定的 Unicode 字元分類至由其中一個 UnicodeCategory 值所識別的群組。Categorizes a specified Unicode character into a group identified by one of the UnicodeCategory values.

GetUnicodeCategory(String, Int32) GetUnicodeCategory(String, Int32) GetUnicodeCategory(String, Int32) GetUnicodeCategory(String, Int32)

將指定字串中指定位置處的字元,分類至由其中一個 UnicodeCategory 值所識別的群組。Categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values.

GetUnicodeCategory(Char) GetUnicodeCategory(Char) GetUnicodeCategory(Char) GetUnicodeCategory(Char)

將指定的 Unicode 字元分類至由其中一個 UnicodeCategory 值所識別的群組。Categorizes a specified Unicode character into a group identified by one of the UnicodeCategory values.

public:
 static System::Globalization::UnicodeCategory GetUnicodeCategory(char c);
public static System.Globalization.UnicodeCategory GetUnicodeCategory (char c);
static member GetUnicodeCategory : char -> System.Globalization.UnicodeCategory
Public Shared Function GetUnicodeCategory (c As Char) As UnicodeCategory

參數

c
Char Char Char Char

要分類的 Unicode 字元。The Unicode character to categorize.

傳回

UnicodeCategory 值,指出包含 c 的群組。A UnicodeCategory value that identifies the group that contains c.

範例

下列程式碼範例將GetUnicodeCategory示範。The following code example demonstrates GetUnicodeCategory.

using namespace System;
int main()
{
   char ch2 = '2';
   String^ str = "Upper Case";
   Console::WriteLine( Char::GetUnicodeCategory( 'a' ).ToString() ); // Output: S"LowercaseLetter"
   Console::WriteLine( Char::GetUnicodeCategory( ch2 ).ToString() ); // Output: S"DecimalDigitNumber"
   Console::WriteLine( Char::GetUnicodeCategory( str, 6 ).ToString() ); // Output: S"UppercaseLetter"
}

using System;

public class GetUnicodeCategorySample {
    public static void Main() {
        char ch2 = '2';
        string str = "Upper Case";

        Console.WriteLine(Char.GetUnicodeCategory('a'));		// Output: "LowercaseLetter"
        Console.WriteLine(Char.GetUnicodeCategory(ch2));		// Output: "DecimalDigitNumber"
        Console.WriteLine(Char.GetUnicodeCategory(str, 6));		// Output: "UppercaseLetter"
    }
}
Module GetUnicodeCategorySample

    Sub Main()

        Dim ch2 As Char
        ch2 = "2"c
        Dim str As String
        str = "Upper Case"

        Console.WriteLine(Char.GetUnicodeCategory("a"c))    ' Output: "1" (LowercaseLetter)
        Console.WriteLine(Char.GetUnicodeCategory(ch2))     ' Output: "8" (DecimalDigitNumber)
        Console.WriteLine(Char.GetUnicodeCategory(str, 6))  ' Output: "0" (UppercaseLetter)

    End Sub

End Module

備註

方法在傳遞特定字元做為參數UnicodeCategory時,不CharUnicodeInfo.GetUnicodeCategory(Char)一定會傳回與方法相同的值。 Char.GetUnicodeCategoryThe Char.GetUnicodeCategory method does not always return the same UnicodeCategory value as the CharUnicodeInfo.GetUnicodeCategory(Char) method when it is passed a particular character as a parameter. CharUnicodeInfo.GetUnicodeCategory(Char)方法是設計來反映 Unicode 標準的目前版本。The CharUnicodeInfo.GetUnicodeCategory(Char) method is designed to reflect the current version of the Unicode standard. 相反地,雖然Char.GetUnicodeCategory方法通常會反映 Unicode 標準的目前版本,但它可能會根據舊版標準來傳回字元的類別目錄,或者它可能會傳回與目前標準順序不同的類別目錄。以保留回溯相容性。In contrast, although the Char.GetUnicodeCategory method usually reflects the current version of the Unicode standard, it may return a character's category based on a previous version of the standard or it may return a category that differs from the current standard in order to preserve backward compatibility. 因此,建議您使用CharUnicodeInfo.GetUnicodeCategory(Char)方法, Char.GetUnicodeCategory(Char)而不要使用。As a result, we recommend that you use the CharUnicodeInfo.GetUnicodeCategory(Char) method instead of Char.GetUnicodeCategory(Char).

從開始,unicode 字元會根據unicode 標準版本 8.0.0來分類。 .NET Framework 4.6.2.NET Framework 4.6.2Starting with the .NET Framework 4.6.2.NET Framework 4.6.2, Unicode characters are classified based on The Unicode Standard, Version 8.0.0. 在的 .NET Framework .NET Framework 4.NET Framework 4版本中.NET Framework 4.6.1.NET Framework 4.6.1,會根據Unicode 標準版本 6.3.0來分類。In versions of the .NET Framework from the .NET Framework 4.NET Framework 4 to the .NET Framework 4.6.1.NET Framework 4.6.1, they are classified based on The Unicode Standard, Version 6.3.0.

另請參閱

GetUnicodeCategory(String, Int32) GetUnicodeCategory(String, Int32) GetUnicodeCategory(String, Int32) GetUnicodeCategory(String, Int32)

將指定字串中指定位置處的字元,分類至由其中一個 UnicodeCategory 值所識別的群組。Categorizes the character at the specified position in a specified string into a group identified by one of the UnicodeCategory values.

public:
 static System::Globalization::UnicodeCategory GetUnicodeCategory(System::String ^ s, int index);
public static System.Globalization.UnicodeCategory GetUnicodeCategory (string s, int index);
static member GetUnicodeCategory : string * int -> System.Globalization.UnicodeCategory
Public Shared Function GetUnicodeCategory (s As String, index As Integer) As UnicodeCategory

參數

index
Int32 Int32 Int32 Int32

s 中的字元位置。The character position in s.

傳回

UnicodeCategory 列舉常數,指出包含在 index 中位於 s 之字元的群組。A UnicodeCategory enumerated constant that identifies the group that contains the character at position index in s.

例外狀況

index 小於零或大於 s 中的最後一個位置。index is less than zero or greater than the last position in s.

範例

下列範例會示範GetUnicodeCategoryThe following example demonstrates GetUnicodeCategory.

using namespace System;
int main()
{
   char ch2 = '2';
   String^ str = "Upper Case";
   Console::WriteLine( Char::GetUnicodeCategory( 'a' ).ToString() ); // Output: S"LowercaseLetter"
   Console::WriteLine( Char::GetUnicodeCategory( ch2 ).ToString() ); // Output: S"DecimalDigitNumber"
   Console::WriteLine( Char::GetUnicodeCategory( str, 6 ).ToString() ); // Output: S"UppercaseLetter"
}

using System;

public class GetUnicodeCategorySample {
    public static void Main() {
        char ch2 = '2';
        string str = "Upper Case";

        Console.WriteLine(Char.GetUnicodeCategory('a'));		// Output: "LowercaseLetter"
        Console.WriteLine(Char.GetUnicodeCategory(ch2));		// Output: "DecimalDigitNumber"
        Console.WriteLine(Char.GetUnicodeCategory(str, 6));		// Output: "UppercaseLetter"
    }
}
Module GetUnicodeCategorySample

    Sub Main()

        Dim ch2 As Char
        ch2 = "2"c
        Dim str As String
        str = "Upper Case"

        Console.WriteLine(Char.GetUnicodeCategory("a"c))    ' Output: "1" (LowercaseLetter)
        Console.WriteLine(Char.GetUnicodeCategory(ch2))     ' Output: "8" (DecimalDigitNumber)
        Console.WriteLine(Char.GetUnicodeCategory(str, 6))  ' Output: "0" (UppercaseLetter)

    End Sub

End Module

備註

字串中的字元位置會從零開始編制索引。Character positions in a string are indexed starting from zero.

方法在傳遞特定字元做為參數UnicodeCategory時,不CharUnicodeInfo.GetUnicodeCategory(String, Int32)一定會傳回與方法相同的值。 Char.GetUnicodeCategoryThe Char.GetUnicodeCategory method does not always return the same UnicodeCategory value as the CharUnicodeInfo.GetUnicodeCategory(String, Int32) method when it is passed a particular character as a parameter. CharUnicodeInfo.GetUnicodeCategory(String, Int32)方法是設計來反映 Unicode 標準的目前版本。The CharUnicodeInfo.GetUnicodeCategory(String, Int32) method is designed to reflect the current version of the Unicode standard. 相反地,雖然Char.GetUnicodeCategory方法通常會反映 Unicode 標準的目前版本,但它可能會根據舊版標準來傳回字元的類別目錄,或者它可能會傳回與目前標準順序不同的類別目錄。以保留回溯相容性。In contrast, although the Char.GetUnicodeCategory method usually reflects the current version of the Unicode standard, it may return a character's category based on a previous version of the standard or it may return a category that differs from the current standard in order to preserve backward compatibility. 因此,建議您使用CharUnicodeInfo.GetUnicodeCategory(Char)方法, Char.GetUnicodeCategory(String, Int32)而不要使用。As a result, we recommend that you use the CharUnicodeInfo.GetUnicodeCategory(Char) method instead of Char.GetUnicodeCategory(String, Int32).

從開始,unicode 字元會根據unicode 標準版本 8.0.0來分類。 .NET Framework 4.6.2.NET Framework 4.6.2Starting with the .NET Framework 4.6.2.NET Framework 4.6.2, Unicode characters are classified based on The Unicode Standard, Version 8.0.0. 在的 .NET Framework .NET Framework 4.NET Framework 4版本中.NET Framework 4.6.1.NET Framework 4.6.1,會根據Unicode 標準版本 6.3.0來分類。In versions of the .NET Framework from the .NET Framework 4.NET Framework 4 to the .NET Framework 4.6.1.NET Framework 4.6.1, they are classified based on The Unicode Standard, Version 6.3.0.

另請參閱

適用於