C# Char GetNumericValue(String, Int32)
Description
Char GetNumericValue(String, Int32)
converts the numeric
Unicode character at the specified position in a specified string to a double-precision
floating point number.
Syntax
Char.GetNumericValue(String, Int32)
has the following syntax.
public static double GetNumericValue(
string s,
int index
)
Parameters
Char.GetNumericValue(String, Int32)
has the following parameters.
s
- A String.index
- The character position in s.
Returns
Char.GetNumericValue(String, Int32)
method returns The numeric value of the character at position index in s if that character
represents a number; otherwise, -1.
Example
The following code example demonstrates GetNumericValue.
// ww w .j av a 2 s. co m
using System;
public class MainClass {
public static void Main() {
string str = "input: 1";
Console.WriteLine(Char.GetNumericValue(str, 7)); // Output: "1"
}
}
The code above generates the following result.