Export (0) Print
Expand All

Char.GetNumericValue Method (Char)

Converts the specified numeric Unicode character to a double-precision floating point number.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

'Declaration
Public Shared Function GetNumericValue ( _
	c As Char _
) As Double
'Usage
Dim c As Char
Dim returnValue As Double

returnValue = Char.GetNumericValue(c)
public static double GetNumericValue (
	char c
)
public static function GetNumericValue (
	c : char
) : double

Parameters

c

A Unicode character.

Return Value

The numeric value of c if that character represents a number; otherwise, -1.0.

For example, if c is '5', the return value is 5. However, if c is 'z', the return value is -1.0.

A character has an associated numeric value if and only if it is a member of one of the following categories in UnicodeCategory: DecimalDigitNumber, LetterNumber, or OtherNumber.

The following code example demonstrates 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

import System.*;

public class GetNumericValueSample
{
    public static void main(String[] args)
    {
        String str = "input:  1";
      
        Console.WriteLine(Char.GetNumericValue('8')); // Output: "8"
        Console.WriteLine(Char.GetNumericValue(str, 8)); // Output: "1"
    } //main
} //GetNumericValueSample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft