C# | Convert.GetTypeCode(Object) Method Last Updated : 02 Sep, 2021 Comments Improve Suggest changes Like Article Like Report This method is used to return the TypeCode for the specified object.Syntax: public static TypeCode GetTypeCode (object value); Here, the value is an object that implements the IConvertible interface.Return Value: This method returns the TypeCode for value, or Empty if value is null.Below programs illustrate the use of Convert.GetTypeCode(Object) Method:Example 1: csharp // C# program to demonstrate // Convert.GetTypeCode() Method using System; class GFG { // Main Method public static void Main() { // Declaring val1 and val2 string val1; bool val2; // initializing the // val1 and val2 val1 = "abab"; val2 = true; // getting TypeCode // using Convert.GetTypeCode() method TypeCode t1 = Convert.GetTypeCode(val1); TypeCode t2 = Convert.GetTypeCode(val2); // Display TypeCode Console.WriteLine("TypeCode of val1 is {0}", t1); Console.WriteLine("TypeCode of val2 is {0}", t2); } } Output: TypeCode of val1 is String TypeCode of val2 is Boolean Example 2: csharp // C# program to demonstrate // Convert.GetTypeCode() Method using System; class GFG { // Main Method public static void Main() { // Declaring val1 and val2 char val1; float val2; // initializing 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 Convert.GetTypeCode() method TypeCode t = Convert.GetTypeCode(val); // 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 = Convert.GetTypeCode(val); // Display the TypeCode Console.WriteLine("TypeCode of {0}"+ " is {1}", val, t); } } Output: TypeCode of a is Char TypeCode of 20 is Single Reference: https://docs.microsoft.com/en-us/dotnet/api/system.convert.gettypecode?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Convert.GetTypeCode(Object) Method R rohitprasad3 Follow Improve Article Tags : C# CSharp-method CSharp Convert Class Similar Reads C# | Object.GetTypeCode() Method with Examples This method is used to return the Type of the current instance. Here, Type Represents type declarations i.e. class types, interface types, array types, value types, enumeration types, type parameters, generic type definitions, and open or closed constructed generic types. The System.Object class is 3 min read C# | Type.GetTypeCode() Method Type.GetTypeCode() Method is used to get the underlying type code of the specified Type. Syntax: public static TypeCode GetTypeCode (Type type); Here, it takes the type whose underlying type code to get. Return Value: This method returns the code of the underlying type, or Empty if type is null. Bel 2 min read C# | Byte.GetTypeCode() Method This method is used to return the TypeCode for value type Byte. Syntax: public TypeCode GetTypeCode (); Return Value: It returns the enumerated constant, Byte.Below programs illustrate the use of Byte.GetTypeCode() Method:Example 1: CSharp // C# program to demonstrate // Byte.GetTypeCode() Method us 2 min read DateTime.GetTypeCode() Method in C# This method is used to return the TypeCode for value type DateTime. Syntax: public TypeCode GetTypeCode (); Return Value: This method returns the enumerated constant, DateTime. Below programs illustrate the use of DateTime.GetTypeCode() Method Example 1: csharp // C# program to demonstrate the // Da 1 min read 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: csharp // C# program to demonstrate // Char.GetTypeCode() 2 min read Like