Char.IsNumber 메서드

정의

유니코드 문자가 숫자인지 여부를 나타냅니다.

오버로드

IsNumber(String, Int32)

지정된 문자열의 지정된 위치에 있는 문자가 숫자인지 여부를 나타냅니다.

IsNumber(Char)

지정된 유니코드 문자가 숫자인지 여부를 나타냅니다.

IsNumber(String, Int32)

지정된 문자열의 지정된 위치에 있는 문자가 숫자인지 여부를 나타냅니다.

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에서 평가할 문자의 위치입니다.

반환

Boolean

indexs 위치에 있는 문자가 숫자이면 true이고 그렇지 않으면 false입니다.

예외

s이(가) null인 경우

index가 0보다 작거나 s의 마지막 위치보다 큽니다.

예제

다음 예제에서는을 보여 줍니다 IsNumber .

using namespace System;
int main()
{
   String^ str =  "non-numeric";
   Console::WriteLine( Char::IsNumber( '8' ) ); // Output: "True"
   Console::WriteLine( Char::IsNumber( str, 3 ) ); // Output: "False"
}
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 가 숫자 유니코드 범주 인지 여부를 확인 합니다. 숫자를 포함 하는 것 외에도 문자, 분수, 아래 첨자, 위 첨자, 로마 숫자, 통화 분자 및 encircled 숫자가 포함 됩니다. 이 메서드는가 IsDigit Char 기 수-10 자리 인지 여부를 결정 하는 메서드와 대조 됩니다.

문자열의 문자 위치는 0부터 시작 하는 인덱스입니다.

중요

메서드는 문자열 IsNumber(String, Int32) 의 각 문자에 대해 메서드를 호출 하는 등의 방법으로 문자열이 숫자 문자로 구성 되어 있는지 여부를 확인 하기 위한 것이 아닙니다. 문자열이 숫자 문자로 구성 되어 있는지 확인 하려면 TryParse Int32.TryParse Double.TryParse 정수 계열 또는 부동 소수점 형식의 또는와 같은 메서드의 오버 로드 중 하나를 호출 합니다.

유효한 숫자는 UnicodeCategory.DecimalDigitNumber , UnicodeCategory.LetterNumber 또는 범주의 멤버입니다 UnicodeCategory.OtherNumber .

Char위치의 개체가 index 유효한 서로게이트 쌍의 첫 번째 문자인 경우 IsNumber(String, Int32) 메서드는 서로게이트 쌍이 숫자를 형성 하는지 여부를 확인 합니다. 예를 들어 Aegean 번호 매기기 시스템은 U + 10107 ~ U + 10133 코드 포인트로 구성 됩니다. 다음 예제에서는 메서드를 사용 하 여 ConvertFromUtf32 AEGEAN NUMBER ONE을 나타내는 문자열을 인스턴스화합니다. 예제의 출력에 표시 된 것 처럼 메서드는 IsNumber(String, Int32) true AEGEAN NUMBER ONE의 상위 서로게이트를 전달 하는 경우를 반환 합니다. 그러나 하위 서로게이트를 전달 하는 경우 하위 서로게이트의 범주만 고려 하 여를 반환 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

추가 정보

적용 대상

IsNumber(Char)

지정된 유니코드 문자가 숫자인지 여부를 나타냅니다.

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

평가할 유니코드 문자입니다.

반환

Boolean

c가 숫자이면 true이고 그렇지 않으면 false입니다.

예제

다음 예제에서는을 보여 줍니다 IsNumber .

using namespace System;
int main()
{
   String^ str =  "non-numeric";
   Console::WriteLine( Char::IsNumber( '8' ) ); // Output: "True"
   Console::WriteLine( Char::IsNumber( str, 3 ) ); // Output: "False"
}
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 가 숫자 유니코드 범주 인지 여부를 확인 합니다. 숫자를 포함 하는 것 외에도 문자, 분수, 아래 첨자, 위 첨자, 로마 숫자, 통화 분자 및 encircled 숫자가 포함 됩니다. 이 메서드는가 IsDigit Char 기 수-10 자리 인지 여부를 결정 하는 메서드와 대조 됩니다.

중요

메서드는 문자열 IsNumber(Char) 의 각 문자에 대해 메서드를 호출 하는 등의 방법으로 문자열이 숫자 문자로 구성 되어 있는지 여부를 확인 하기 위한 것이 아닙니다. 문자열이 숫자 문자로 구성 되어 있는지 확인 하려면 TryParse Int32.TryParse Double.TryParse 정수 계열 또는 부동 소수점 형식의 또는와 같은 메서드의 오버 로드 중 하나를 호출 합니다.

유효한 숫자는 UnicodeCategory.DecimalDigitNumber , UnicodeCategory.LetterNumber 또는 범주의 멤버입니다 UnicodeCategory.OtherNumber .

IsNumber(Char)이 메서드는가 c 단일 언어 문자에 해당 하는 것으로 가정 하 고 해당 문자가 숫자를 나타내는지 여부를 확인 합니다. 그러나 유니코드 표준의 일부 숫자는 Char 서로게이트 쌍을 형성 하는 두 개의 개체로 표현 됩니다. 예를 들어 Aegean 번호 매기기 시스템은 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

추가 정보

적용 대상