C# Program to Demonstrate the Use of Reflection to Get Namespace and Base-Type

You are currently viewing C# Program to Demonstrate the Use of Reflection to Get Namespace and Base-Type

C# program to demonstrate the use of reflection to get namespace and base-type

// C# program to demonstrate the use of reflection 
//to get namespace and base type.

using System;
using System.Reflection;

class RefDemo
{
    static void Main()
    {
        Type type;
        
        type = typeof(int);
        Console.WriteLine("Data Type Name : "+ type.Name        );
        Console.WriteLine("Full Type Name : "+ type.FullName    );
        Console.WriteLine("Namespace      : "+ type.Namespace   );
        Console.WriteLine("Base Type      : "+ type.BaseType    );
    }
}

output

Data Type Name : Int32
Full Type Name : System.Int32
Namespace      : System
Base Type      : System.ValueType
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply