指定した文字列の指定位置にある Unicode の数字を倍精度浮動小数点数に変換します。
Overloads Public Shared Function GetNumericValue( _
ByVal s As String, _ ByVal index As Integer _) As Double
[C#]
public static double GetNumericValue(strings,intindex);
[C++]
public: static double GetNumericValue(String* s,intindex);
[JScript]
public static function GetNumericValue(
s : String,index : int) : double;
パラメータ
- s
String 。 - index
s 内の文字位置。
戻り値
この文字が数字の場合は、 s の index の位置のこの文字の数値。それ以外の場合は -1。
例外
例外の種類 | 条件 |
---|---|
ArgumentNullException | s が null 参照 (Visual Basic では Nothing) です。 |
ArgumentOutOfRangeException | index が 0 未満か、 s の最後の位置より大きい値です。 |
解説
たとえば、 s の index の位置の文字が 5 の場合、戻り値は 5 です。ただし s の index の位置の文字が z の場合、戻り値は -1 です。
文字列の文字位置には、0 から始まるインデックスが付けられます。
文字は、 UnicodeCategory のカテゴリ DecimalDigitNumber 、 LetterNumber 、または OtherNumber のいずれかのメンバである場合にだけ、関連付けられた数値を持ちます。
使用例
[Visual Basic, C#, C++] GetNumericValue のサンプルを次に示します。
Imports System
Module GetNumericValueSample
Sub Main()
Dim str As String
str = "input: 1"
Console.WriteLine(Char.GetNumericValue("8"c)) ' Output: "8"
Console.WriteLine(Char.GetNumericValue(str, 7)) ' Output: "1"
End Sub
End Module
[C#]
using System;
public class GetNumericValueSample {
public static void Main() {
string str = "input: 1";
Console.WriteLine(Char.GetNumericValue('8')); // Output: "8"
Console.WriteLine(Char.GetNumericValue(str, 8)); // Output: "1"
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
int main() {
String* str = "input: 1";
Console::WriteLine(Char::GetNumericValue('8')); // Output: "8"
Console::WriteLine(Char::GetNumericValue(str, 7)); // Output: "1"
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard
参照
Char 構造体 | Char メンバ | System 名前空間 | Char.GetNumericValue オーバーロードの一覧