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:
- Classes, which are derived from System.Object.
- Value types, which are derived from System.ValueType.
- Interfaces, which are derived from System.Object starting with the .NET Framework 2.0.
- Enumerations, which are derived from System.Enum.
- Delegates, which are derived from System.MulticastDelegate.
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:
The X class object type is: X The G class object type is: G The obj2 object type is: X
Author details: Author Name : Kirti Article Name : GetType() method Article No : 3 Type of Author Name : System.String Type of Article Name : System.String Type of Article No : System.Int32 Type of Author class object: Author
- 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 email@example.com. 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.