Get all the public properties of the current Type in CSharp

Description

The following code shows how to get all the public properties of the current Type.

Example


using System;/*from ww  w .  j  a v a2  s  .  co m*/
using System.Reflection;
using System.Reflection.Emit;

public class MainClass
{
    public static void Main()
    {
        PropertyInfo[] myPropertyInfo;
        myPropertyInfo = Type.GetType("System.Type").GetProperties();
        Console.WriteLine("Properties of System.Type are:");
        for (int i = 0; i < myPropertyInfo.Length; i++)
        {
            Console.WriteLine(myPropertyInfo[i].ToString());
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Reflection »




Array
Constructor
Event
Field
Interface
Method
Properties
Type