C# TypeInfo DeclaredProperties

Description

TypeInfo DeclaredProperties Gets a collection of the properties defined by the current type.

Syntax

TypeInfo.DeclaredProperties has the following syntax.


public virtual IEnumerable<PropertyInfo> DeclaredProperties { get; }

Example


using System;//ww  w.j  ava2  s.  c o  m
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Globalization;
using System.Text;


public class MainClass
{
    public static void Main(String[] argv){    
        TypeInfo t = typeof(Calendar).GetTypeInfo();
        IEnumerable<PropertyInfo> pList = t.DeclaredProperties;
        IEnumerable<MethodInfo> mList = t.DeclaredMethods;

        StringBuilder sb = new StringBuilder();

        sb.Append("Properties:");
        foreach (PropertyInfo p in pList)
        {

            sb.Append("\n" + p.DeclaringType.Name + ": " + p.Name);
        }
        sb.Append("\nMethods:");
        foreach (MethodInfo m in mList)
        {
            sb.Append("\n" + m.DeclaringType.Name + ": " + m.Name);
        }

        Console.WriteLine(sb.ToString());

    }
}




















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo