C# 中的 Char.GetUnicodeCategory(String, Int32) 方法將指定字符串中指定位置的字符分類到由 UnicodeCategory 值之一標識的組中。
用法
以下是語法 -
public static System.Globalization.UnicodeCategory GetUnicodeCategory (string str, int index);
上麵,str 是一個字符串,而 index 是 str 中的字符位置。
示例
現在讓我們看一個實現 Char.GetUnicodeCategory(String, Int32) 方法的例子 -
using System;
using System.Globalization;
public class Demo {
public static void Main(){
string val = "amit";
UnicodeCategory unicode = Char.GetUnicodeCategory(val, 2);
Console.WriteLine("The value at specific index = "+unicode);
}
}
輸出
這將產生以下輸出 -
LowercaseLetter
示例
現在讓我們看另一個例子 -
using System;
using System.Globalization;
public class Demo {
public static void Main(){
string val = "hjk9878hj";
UnicodeCategory unicode = Char.GetUnicodeCategory(val, 4);
Console.WriteLine("The value at specific index = "+unicode);
}
}
輸出
這將產生以下輸出 -
The value at specific index = DecimalDigitNumber
相關用法
- C# Char.GetHashCode()用法及代碼示例
- C# Char.GetNumericValue()用法及代碼示例
- C# Char.GetTypeCode()用法及代碼示例
- C# Char.TryParse()用法及代碼示例
- C# Char.IsUpper()用法及代碼示例
- C# Char.IsSymbol()用法及代碼示例
- C# Char.Parse(String)用法及代碼示例
- C# Char.IsSurrogatePair(String, Int32)用法及代碼示例
- C# Char.CompareTo()用法及代碼示例
- C# Char.ToString()用法及代碼示例
- C# Char.IsNumber()用法及代碼示例
- C# Char.ToUpperInvariant(Char)用法及代碼示例
- C# Char.ToLowerInvariant(Char)用法及代碼示例
- C# Char.IsHighSurrogate(String, Int32)用法及代碼示例
- C# Char.IsLetter()用法及代碼示例
- C# Char.ConvertToUtf32(String, Int32)用法及代碼示例
- C# Char.IsSurrogate(String, Int32)用法及代碼示例
- C# Char.IsControl(String, Int32)用法及代碼示例
- C# Char.ConvertFromUtf32(Int32)用法及代碼示例
- C# Char.IsSeparator()用法及代碼示例
注:本文由純淨天空篩選整理自AmitDiwan大神的英文原創作品 Char.GetUnicodeCategory(String, Int32) Method with Examples in C#。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。