This method is used to return the TypeCode for value type Char.
Syntax:
public TypeCode GetTypeCode ();
Return Value: This method returns the enumerated constant, Char.
Below programs illustrate the use of Char.GetTypeCode() Method:
Example 1:
csharp
using System;
class GFG {
public static void Main()
{
char val1;
bool val2;
val1 = 'A' ;
val2 = true ;
TypeCode t1 = val1.GetTypeCode();
TypeCode t2 = val2.GetTypeCode();
Console.WriteLine( "TypeCode of val1 is {0}" , t1);
Console.WriteLine( "TypeCode of val2 is {0}" , t2);
}
}
|
Output:
TypeCode of val1 is Char
TypeCode of val2 is Boolean
Example 2:
csharp
using System;
class GFG {
public static void Main()
{
char val1;
float val2;
val1 = 'a' ;
val2 = 20f;
get (val1);
get (val2);
}
public static void get ( char val)
{
TypeCode t = val.GetTypeCode();
Console.WriteLine( "TypeCode of {0} is {1}" ,
val, t);
}
public static void get ( float val)
{
TypeCode t = val.GetTypeCode();
Console.WriteLine( "TypeCode of {0} is {1}" ,
val, t);
}
}
|
Output:
TypeCode of a is Char
TypeCode of 20 is Single
Reference:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
11 Aug, 2021
Like Article
Save Article