Char.GetTypeCode() Method with Examples in C#


The Char.GetTypeCode() method in C# is used to return the TypeCode for value type Char.

Syntax

Following is the syntax −

public TypeCode GetTypeCode ();

Example

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

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));
      TypeCode type = val.GetTypeCode();
      Console.WriteLine("Type = "+type);
   }
}

Output

This will produce the following output −

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

Example

Let us now see another example −

using System;
public class Demo {
   public static void Main(){
      char val = 'B';
      TypeCode type = val.GetTypeCode();
      Console.WriteLine("Type = "+type);
   }
}

Output

This will produce the following output −

Type = Char

Updated on: 12-Nov-2019

42 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements