Get BaseType, Name, FullName and Namespace for a type : Type : Reflection C# Examples


C# Examples » Reflection » Type »

 

Get BaseType, Name, FullName and Namespace for a type









    
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);
    }  
}
    
   
  
   



Output

Object
System.Object
System
System.Object
String
System.String
System


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Reflection
» Type