C# Char GetNumericValue(Char)
Description
Char GetNumericValue(Char)
converts the specified
numeric Unicode character to a double-precision floating point number.
Syntax
Char.GetNumericValue(Char)
has the following syntax.
public static double GetNumericValue(
char c
)
Parameters
Char.GetNumericValue(Char)
has the following parameters.
c
- The Unicode character to convert.
Returns
Char.GetNumericValue(Char)
method returns The numeric value of c if that character represents a number; otherwise,
-1.0.
Example
The following example demonstrates GetNumericValue.
/*w ww .ja v a2 s.c o m*/
using System;
public class MainClass {
public static void Main() {
string str = "input: 1";
Console.WriteLine(Char.GetNumericValue('8')); // Output: "8"
Console.WriteLine(Char.GetNumericValue(str, 7)); // Output: "1"
}
}
The code above generates the following result.