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 the base class for all the types which are present in the
.NET Framework type system. Basically, this method returns the Type objects that represent all
.NET Framework types.
The .NET Framework recognizes the following five categories of types:
Syntax:
public Type GetType ();
Return Value: This method returns the run-time type of the current instance.
Below programs illustrate the use of
Object.GetType() Method:
Example 1:
Output:
The X class object type is: X
The G class object type is: G
The obj2 object type is: X
Example 2: