■ PropertyInfo 배열 구하기 예제

----------------------------------------------------------------------------------------------------

using System;

using System.Reflection;

using System.Windows.Forms;

 

PropertyInfo[] propertyInfoArray = GetPropertyInfoArray<Form>(BindingFlags.Public | BindingFlags.Instance);

 

foreach(PropertyInfo propertyInfo in propertyInfoArray)

{

    Console.WriteLine(propertyInfo.Name);

}

----------------------------------------------------------------------------------------------------

 

■ PropertyInfo 배열 구하기

----------------------------------------------------------------------------------------------------

using System.Reflection;

 

#region PropertyInfo 배열 구하기 - GetPropertyInfoArray<T>(bindingFlags)

 

/// <summary>

/// PropertyInfo 배열 구하기

/// </summary>

/// <typeparam name="T">속성 소유자 타입</typeparam>

/// <param name="bindingFlags">BindingFlags</param>

/// <returns>PropertyInfo 배열</returns>

public PropertyInfo[] GetPropertyInfoArray<T>(BindingFlags bindingFlags)

{

    return typeof(T).GetProperties(bindingFlags);

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요