VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-getting-the-type-of-the-current-instance/

⇱ C# | Getting the type of the current instance - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Getting the type of the current instance

Last Updated : 11 Jul, 2025
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 to understand the implementation in a better way: Example 1: Output:
Type of str1: System.String
Type of str2: System.String
Example 2:
Output:
Str 1 is : C#
Str 2 is : DSA
Str 3 is : 43
Is Str 1 and Str 2 of same type? : True
Is Str 2 and Str 3 of same type? : False
Is Str 3 and Str 2 of same type? : False
Reference:
Comment
Article Tags:
Article Tags:

Explore