Char.GetNumericValue() Method in C#


The Char.GetNumericValue() method in C# is used to convert the specified numeric Unicode character to a double-precision floating-point number.

Syntax

Following is the syntax −

public static double GetNumericValue (char ch);

Above, the parameter ch is the Unicode character to convert.

Example

Let us now see an example to implement the Char.GetNumericValue() method −

using System;
public class Demo {
   public static void Main(){
      char val = 'm';
      bool res;
      Console.WriteLine("Hashcode for val = "+val.GetHashCode());
      res = val.Equals('m');
      Console.WriteLine("Return Value = "+res);
      Console.WriteLine("Numeric Value = "+Char.GetNumericValue(val));
   }
}

Output

This will produce the following output −

Hashcode for val = 7143533
Return Value = True
Numeric Value = -1

Example

Let us now see another example −

using System;
public class Demo {
   public static void Main(){
      char val = '5';
      bool res;
      Console.WriteLine("Hashcode for val = "+val.GetHashCode());
      res = val.Equals('m');
      Console.WriteLine("Return Value = "+res);
      Console.WriteLine("Numeric Value = "+Char.GetNumericValue(val));
   }
}

Output

This will produce the following output −

Hashcode for val = 3473461
Return Value = False
Numeric Value = 5

Updated on: 12-Nov-2019

386 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements