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.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version