Indicates whether a Unicode character is categorized as a number.
Overload List
Indicates whether the specified Unicode character is categorized as a number.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Function IsNumber(Char) As Boolean
[C#] public static bool IsNumber(char);
[C++] public: static bool IsNumber(__wchar_t);
[JScript] public static function IsNumber(Char) : Boolean;
Indicates whether the character at the specified position in a specified string is categorized as a number.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Function IsNumber(String, Integer) As Boolean
[C#] public static bool IsNumber(string, int);
[C++] public: static bool IsNumber(String*, int);
[JScript] public static function IsNumber(String, int) : Boolean;
Example
[Visual Basic, C#, C++] The following sample demonstrates IsNumber.
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of IsNumber. For other examples that might be available, see the individual overload topics.
[Visual Basic]
Imports System
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
[C#]
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"
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
int main() {
String* str = "non-numeric";
Console::WriteLine(Char::IsNumber('8')); // Output: "True"
Console::WriteLine(Char::IsNumber(str, 3)); // Output: "False"
}
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
See Also
Char Structure | Char Members | System Namespace