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.





















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