Returns all the public properties of the current System.Type. - CSharp System.Reflection

CSharp examples for System.Reflection:PropertyInfo

Description

Returns all the public properties of the current System.Type.

Demo Code

// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html
using System.Reflection;
using System.Linq;
using System;//from ww  w  . j a va  2 s .com

public class Main{
        /// <summary>
      /// Returns all the public properties of the current System.Type.
      /// </summary>
      /// <param name="type">The type.</param>
      /// <returns>An array of System.Reflection.PropertyInfo objects representing all public properties of the current System.Type.-or- An empty array of type System.Reflection.PropertyInfo, if the current System.Type does not have public properties.</returns>
      public static PropertyInfo[] GetProperties( this Type type )
      {
         return type.GetRuntimeProperties().ToArray();
      }
}

Related Tutorials