Object.GetType() : Object « System « C# / C Sharp by API






Object.GetType()


using System;

class MainClass
{
  static void Main(string[] args)
  {
    Object cls1 = new Object();
    System.String cls2 = "Test String" ;

    Type type1 = cls1.GetType();
    Type type2 = cls2.GetType();

    // Object class output
    Console.WriteLine(type1.BaseType);
    Console.WriteLine(type1.Name);
    Console.WriteLine(type1.FullName);
    Console.WriteLine(type1.Namespace);

    // string output
    Console.WriteLine(type2.BaseType);
    Console.WriteLine(type2.Name);
    Console.WriteLine(type2.FullName);
    Console.WriteLine(type2.Namespace);
  } 
}

 








Related examples in the same category