Char.IsNumber 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
유니코드 문자가 숫자로 분류되는지 여부를 나타냅니다.
오버로드
| Name | Description |
|---|---|
| IsNumber(Char) |
지정된 유니코드 문자가 숫자로 분류되는지 여부를 나타냅니다. |
| IsNumber(String, Int32) |
지정된 문자열의 지정된 위치에 있는 문자가 숫자로 분류되는지 여부를 나타냅니다. |
IsNumber(Char)
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
지정된 유니코드 문자가 숫자로 분류되는지 여부를 나타냅니다.
public:
static bool IsNumber(char c);
public static bool IsNumber(char c);
static member IsNumber : char -> bool
Public Shared Function IsNumber (c As Char) As Boolean
매개 변수
- c
- Char
평가할 유니코드 문자입니다.
반품
예제
다음 예제에서는 IsNumber를 보여줍니다.
using System;
public class IsNumberSample {
public static void Main() {
string str = "non-numeric";
Console.WriteLine(Char.IsNumber('8')); // Output: "True"
Console.WriteLine(Char.IsNumber(str, 3)); // Output: "False"
}
}
open System
let str = "non-numeric"
printfn $"{Char.IsNumber '8'}" // Output: "True"
printfn $"{Char.IsNumber(str, 3)}" // Output: "False"
Module IsNumberSample
Sub Main()
Dim str As String
str = "non-numeric"
Console.WriteLine(Char.IsNumber("8"c)) ' Output: "True"
Console.WriteLine(Char.IsNumber(str, 3)) ' Output: "False"
End Sub
End Module
설명
이 메서드는 숫자 유니코드 범주인지 여부를 Char 결정합니다. 숫자를 포함하는 것 외에도 숫자에는 문자, 분수, 아래 첨자, 위 첨자, 로마 숫자, 통화 숫자 및 둘러싸인 숫자가 포함됩니다. 이 메서드는 radix-10 숫자인지 여부를 IsDigit 결정하는 메서드와 Char 대조됩니다.
Important
이 IsNumber(Char) 메서드는 문자열이 숫자 문자로 구성되는지 여부를 결정하기 위한 것이 아닙니다(예: 문자열의 각 문자에 대한 메서드를 호출). 문자열이 숫자 문자로 구성되는지 여부를 확인하려면 메서드의 TryParse 오버로드 중 하나(예: Int32.TryParse 정수 또는 Double.TryParse 부동 소수점 형식)를 호출합니다.
유효한 숫자는 , UnicodeCategory.DecimalDigitNumber또는 UnicodeCategory.LetterNumber 범주의 UnicodeCategory.OtherNumber멤버입니다.
이 메서드는 IsNumber(Char) 단일 언어 문자에 해당한다고 가정 c 하고 해당 문자가 숫자를 나타내는지 여부를 확인합니다. 그러나 유니코드 표준의 일부 숫자는 서로게이트 쌍을 형성하는 두 Char 개체로 표시됩니다. 예를 들어 에게 해 번호 매기기 시스템은 U+10107~U+10133 코드 포인트로 구성됩니다. 다음 예제에서는 메서드를 ConvertFromUtf32 사용하여 AEGEAN NUMBER ONE을 나타내는 문자열을 인스턴스화합니다. 예제의 출력에서 알 수 있듯이 메서드는 이 문자의 IsNumber(Char) 상위 서로게이트 또는 낮은 서로게이트를 전달하면 반환 false 됩니다.
int utf32 = 0x10107; // AEGEAN NUMBER ONE
string surrogate = Char.ConvertFromUtf32(utf32);
foreach (var ch in surrogate)
Console.WriteLine("U+{0:X4}: {1}", Convert.ToUInt16(ch),
Char.IsNumber(ch));
// The example displays the following output:
// U+D800: False
// U+DD07: False
let utf32 = 0x10107 // AEGEAN NUMBER ONE
let surrogate = Char.ConvertFromUtf32 utf32
for ch in surrogate do
printfn $"U+{Convert.ToUInt16 ch:X4}: {Char.IsNumber ch}"
// The example displays the following output:
// U+D800: False
// U+DD07: False
Dim utf32 As Integer = &h10107 ' AEGEAN NUMBER ONE
Dim surrogate As String = Char.ConvertFromUtf32(utf32)
For Each ch In surrogate
Console.WriteLine("U+{0:X4}: {1}", Convert.ToUInt16(ch),
Char.IsNumber(ch))
Next
' The example displays the following output:
' U+D800: False
' U+DD07: False
추가 정보
적용 대상
IsNumber(String, Int32)
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
- Source:
- Char.cs
지정된 문자열의 지정된 위치에 있는 문자가 숫자로 분류되는지 여부를 나타냅니다.
public:
static bool IsNumber(System::String ^ s, int index);
public static bool IsNumber(string s, int index);
static member IsNumber : string * int -> bool
Public Shared Function IsNumber (s As String, index As Integer) As Boolean
매개 변수
- s
- String
문자열입니다.
- index
- Int32
에서 평가할 문자의 위치입니다.s
반품
true 위치에 index 있는 s 문자가 숫자이면 이고, false그렇지 않으면 .
예외
s은 null입니다.
index 가 0보다 작거나 .의 마지막 위치보다 큽니다 s.
예제
다음 예제에서는 IsNumber를 보여줍니다.
using System;
public class IsNumberSample {
public static void Main() {
string str = "non-numeric";
Console.WriteLine(Char.IsNumber('8')); // Output: "True"
Console.WriteLine(Char.IsNumber(str, 3)); // Output: "False"
}
}
open System
let str = "non-numeric"
printfn $"{Char.IsNumber '8'}" // Output: "True"
printfn $"{Char.IsNumber(str, 3)}" // Output: "False"
Module IsNumberSample
Sub Main()
Dim str As String
str = "non-numeric"
Console.WriteLine(Char.IsNumber("8"c)) ' Output: "True"
Console.WriteLine(Char.IsNumber(str, 3)) ' Output: "False"
End Sub
End Module
설명
이 메서드는 숫자 유니코드 범주인지 여부를 Char 결정합니다. 숫자를 포함하는 것 외에도 숫자에는 문자, 분수, 아래 첨자, 위 첨자, 로마 숫자, 통화 숫자 및 둘러싸인 숫자가 포함됩니다. 이 메서드는 radix-10 숫자인지 여부를 IsDigit 결정하는 메서드와 Char 대조됩니다.
문자열의 문자 위치는 0부터 인덱싱됩니다.
Important
이 IsNumber(String, Int32) 메서드는 문자열이 숫자 문자로 구성되는지 여부를 결정하기 위한 것이 아닙니다(예: 문자열의 각 문자에 대한 메서드를 호출). 문자열이 숫자 문자로 구성되는지 여부를 확인하려면 메서드의 TryParse 오버로드 중 하나(예: Int32.TryParse 정수 또는 Double.TryParse 부동 소수점 형식)를 호출합니다.
유효한 숫자는 , UnicodeCategory.DecimalDigitNumber또는 UnicodeCategory.LetterNumber 범주의 UnicodeCategory.OtherNumber멤버입니다.
위치에 있는 Char 개체가 유효한 서로게이트 쌍의 첫 번째 문자인 경우 메서드는 index 서로게이트 쌍이 숫자 숫자를 형성하는지 여부를 결정 IsNumber(String, Int32) 합니다. 예를 들어 에게 해 번호 매기기 시스템은 U+10107~U+10133 코드 포인트로 구성됩니다. 다음 예제에서는 메서드를 ConvertFromUtf32 사용하여 AEGEAN NUMBER ONE을 나타내는 문자열을 인스턴스화합니다. 예제의 출력에서 알 수 있듯이 메서드 IsNumber(String, Int32) 는 AEGEAN NUMBER ONE의 상위 서로게이트를 전달하면 반환 true 됩니다. 그러나 낮은 서로게이트를 전달하면 하위 서로게이트의 범주만 고려하고 반환됩니다 false.
int utf32 = 0x10107; // AEGEAN NUMBER ONE
string surrogate = Char.ConvertFromUtf32(utf32);
for (int ctr = 0; ctr < surrogate.Length; ctr++)
Console.WriteLine("U+{0:X4} at position {1}: {2}",
Convert.ToUInt16(surrogate[ctr]), ctr,
Char.IsNumber(surrogate, ctr));
// The example displays the following output:
// U+D800 at position 0: True
// U+DD07 at position 1: False
let utf32 = 0x10107 // AEGEAN NUMBER ONE
let surrogate = Char.ConvertFromUtf32 utf32
for i = 0 to surrogate.Length - 1 do
printfn $"U+{Convert.ToUInt16 surrogate[i]:X4} at position {i}: {Char.IsNumber(surrogate, i)}"
// The example displays the following output:
// U+D800 at position 0: True
// U+DD07 at position 1: False
Dim utf32 As Integer = &h10107 ' AEGEAN NUMBER ONE
Dim surrogate As String = Char.ConvertFromUtf32(utf32)
For ctr As Integer = 0 To surrogate.Length - 1
Console.WriteLine("U+{0:X4} at position {1}: {2}",
Convert.ToUInt16(surrogate(ctr)), ctr,
Char.IsNumber(surrogate, ctr))
Next
' The example displays the following output:
' U+D800 at position 0: True
' U+DD07 at position 1: False