C# | How to get TypeCode for the class String Last Updated : 01 Feb, 2019 Comments Improve Suggest changes Like Article Like Report GetTypeCode() method is used to get the TypeCode of the specified string. Here TypeCode enum represents a specific type of object. In TypeCode every data type is represented by a specific number like String is represented by 18, Int32 is represented by 9, etc. Syntax: public TypeCode GetTypeCode (); Return value: This method return an enumerated constant. Below given are some examples to understand the implementation in a better way: Example 1: CSharp // C# program to illustrate the // GetTypeCode() Method using System; class GFG { // Main method public static void Main() { // variables string str1 = "Geeksforgeeks"; int a = 12; // get the TypeCode by // using GetTypeCode() method Console.WriteLine("The TypeCode for {0}': {1}", str1, str1.GetTypeCode()); Console.WriteLine("The TypeCode for '{0}': {1}", a, a.GetTypeCode()); } } Output: The TypeCode for Geeksforgeeks': String The TypeCode for '12': Int32 Example 2: CSharp // C# program to illustrate the // GetTypeCode() Method using System; class GFG { // Main method public static void Main() { // given string String str1 = "Geeks"; // get the TypeCode of the given String // using GetTypeCode() method TypeCode g = str1.GetTypeCode(); Console.WriteLine("TypeCode for '{0}': {1}, Which means it represents a {2}.", str1, g.ToString("D"), g.ToString("F")); } } Output: TypeCode for 'Geeks': 18, Which means it represents a String. Reference: https://docs.microsoft.com/en-us/dotnet/api/system.string.gettypecode?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | How to get TypeCode for the class String A ankita_saini Follow Improve Article Tags : C# CSharp-method CSharp-string Similar Reads How to get the typecode for enum in C#? Enum.GetTypeCode Method is used to get the type code of the underlying type of this enumeration member. Syntax: public TypeCode GetTypeCode (); Returns: This method returns type code of the underlying type of this instance. Exception: This method will give InvalidOperationException if the enumeratio 1 min read C# | How to get the HashCode for the string GetHashCode() method is used to get the hash code of the specified string. When you apply this method to the string this method will return a 32-bit signed integer hash code of the given string. Syntax: public override int GetHashCode (); Return Value: The return type of this method is System.Int32. 2 min read Convert a Character to the String in C# Given a character, the task is to character to the string in C#. Examples: Input : X = 'a' Output : string S = "a" Input : X = 'A' Output : string S = "A" Approach: The idea is to use ToString() method, the argument is the character and it returns string converting Unicode character to the string. / 1 min read C# | Getting the type of the current instance Object.GetType Method is used to find the type of the current instance. This method returns the instances of the Type class that are used for consideration. Syntax: public Type GetType (); Return Value: This method return the exact runtime type of the current instance. Below given are some examples 2 min read C# | Getting the Type of the Tuple's Element A tuple is a data structure which gives you the easiest way to represent a data set. You can get the type of the tuple objects by using the GetType method. This method will return the type of the tuple objects. This method is inherited from the Object Class. Syntax: public Type GetType (); Return Ty 3 min read Like