Char.IsDigit 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示 Unicode 字符是否分类为十进制数字。
重载
| 名称 | 说明 |
|---|---|
| IsDigit(Char) |
指示指定的 Unicode 字符是否分类为十进制数字。 |
| IsDigit(String, Int32) |
指示指定字符串中指定位置处的字符是否归类为十进制数字。 |
示例
下面的代码示例演示了 IsDigit。
using System;
public class IsDigitSample {
public static void Main() {
char ch = '8';
Console.WriteLine(Char.IsDigit(ch)); // Output: "True"
Console.WriteLine(Char.IsDigit("sample string", 7)); // Output: "False"
}
}
open System
let ch = '8'
printfn $"{Char.IsDigit ch}" // Output: "True"
printfn $"""{Char.IsDigit("sample string", 7)}""" // Output: "False"
Module IsDigitSample
Sub Main()
Dim ch8 As Char
ch8 = "8"c
Console.WriteLine(Char.IsDigit(ch8)) ' Output: "True"
Console.WriteLine(Char.IsDigit("sample string", 6)) ' Output: "False"
End Sub
End Module
注解
有效数字是类别的成员 UnicodeCategory.DecimalDigitNumber 。
IsDigit(Char)
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
指示指定的 Unicode 字符是否分类为十进制数字。
public:
static bool IsDigit(char c);
public static bool IsDigit(char c);
static member IsDigit : char -> bool
Public Shared Function IsDigit (c As Char) As Boolean
参数
- c
- Char
要计算的 Unicode 字符。
返回
true 如果 c 为十进制数字,则为 ;否则为 false。
注解
此方法确定 a Char 是否为弧度 10 位。 这与 IsNumber确定一个 Char 是否属于任何数字 Unicode 类别的对比。 数字包括分数、下标、上标、罗马数字、货币分子、包围数字和特定于脚本的数字等字符。
有效数字是类别的成员 UnicodeCategory.DecimalDigitNumber 。
另请参阅
适用于
IsDigit(String, Int32)
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
指示指定字符串中指定位置处的字符是否归类为十进制数字。
public:
static bool IsDigit(System::String ^ s, int index);
public static bool IsDigit(string s, int index);
static member IsDigit : string * int -> bool
Public Shared Function IsDigit (s As String, index As Integer) As Boolean
参数
- s
- String
字符串。
- index
- Int32
要计算的 s字符的位置。
返回
true如果位置indexs处的字符是十进制数字,则为 ;否则为 false。
例外
s 是 null。
index 小于零或大于最后一 s个位置。
注解
此方法确定 a Char 是否为弧度 10 位。 这与 IsNumber确定一个 Char 是否属于任何数字 Unicode 类别的对比。 数字包括分数、下标、上标、罗马数字、货币分子、包围数字和特定于脚本的数字等字符。
字符串中的字符位置从零开始编制索引。
有效数字是类别的成员 UnicodeCategory.DecimalDigitNumber 。