C# | Char.GetTypeCode() Method with Examples
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:
// C# program to demonstrate // Char.GetTypeCode() Method using System; class GFG { // Main Method public static void Main() { // Declaring val1 and val2 char val1; bool val2; // intializing the // val1 and val2 val1 = 'A' ; val2 = true ; // getting TypeCode // using GetTypeCode() method TypeCode t1 = val1.GetTypeCode(); TypeCode t2 = val2.GetTypeCode(); // Display TypeCode Console.WriteLine( "TypeCode of val1 is {0}" , t1); Console.WriteLine( "TypeCode of val2 is {0}" , t2); } } |
chevron_right
filter_none
Output:
TypeCode of val1 is Char TypeCode of val2 is Boolean
Example 2:
// C# program to demonstrate // Char.GetTypeCode() Method using System; class GFG { // Main Method public static void Main() { // Declaring val1 and val2 char val1; float val2; // intializing the // val1 and val2 val1 = 'a' ; val2 = 20f; // calling get() method get (val1); get (val2); } // Defining the get() method public static void get ( char val) { // getting TypeCode // using GetTypeCode() method TypeCode t = val.GetTypeCode(); // Display the TypeCode Console.WriteLine( "TypeCode of {0} is {1}" , val, t); } public static void get ( float val) { // getting TypeCode // using GetTypeCode() method TypeCode t = val.GetTypeCode(); // Display the TypeCode Console.WriteLine( "TypeCode of {0} is {1}" , val, t); } } |
chevron_right
filter_none
Output:
TypeCode of a is Char TypeCode of 20 is Single
Reference:
Recommended Posts:
- MathF.Exp() Method in C# with Examples
- MathF.Pow() Method in C# with Examples
- MathF.Abs() Method in C# with Examples
- MathF.Tan() Method in C# with Examples
- MathF.Min() Method in C# with Examples
- MathF.Max() Method in C# with Examples
- MathF.Log() Method in C# with Examples
- MathF.Cos() Method in C# with Examples
- MathF.Sin() Method in C# with Examples
- Single.Equals() Method in C# with Examples
- UInt16.ToString() Method in C# with Examples | Set - 1
- Single.GetTypeCode Method in C# with Examples
- UInt16.GetHashCode Method in C# with Examples
- Single.GetHashCode() Method in C# with Examples
- MathF.Acos() Method in C# with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.