728x90
반응형
728x170
using System;
using System.Collections.Generic;
using System.Reflection;
#region 속성 정보 딕셔너리 구하기 - GetPropertyInfoDictionary(sourceObject)
/// <summary>
/// 속성 정보 딕셔너리 구하기
/// </summary>
/// <param name="sourceObject">소스 객체</param>
/// <returns>속성 정보 딕셔너리</returns>
public Dictionary<string, PropertyInfo> GetPropertyInfoDictionary(object sourceObject)
{
if(sourceObject == null)
{
return null;
}
Type sourceType = sourceObject.GetType();
PropertyInfo[] propertyInfoArray = sourceType.GetProperties(BindingFlags.Public);
Dictionary<string, PropertyInfo> dictionary = new Dictionary<string, PropertyInfo>();
foreach(PropertyInfo propertyInfo in propertyInfoArray)
{
dictionary.Add(propertyInfo.Name, propertyInfo);
}
return dictionary;
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] DateTime 구조체 : AM/PM 여부 구하기 (0) | 2021.08.21 |
---|---|
[C#/COMMON] Regex 클래스 : Replace 메소드를 사용해 영숫자 문자가 아닌 경우 제거하기 (0) | 2021.08.21 |
[C#/COMMON] 정수 덧셈하기 (0) | 2021.08.21 |
[C#/COMMON] 숫자 포맷 문자열 사용하기 (0) | 2021.08.21 |
[C#/COMMON] Console 클래스 : Beep 정적 메소드를 사용해 Beep 음 발생시키기 (0) | 2021.08.20 |
[C#/COMMON] BitConverter 클래스 : GetBytes 정적 메소드를 사용해 정수의 바이트 배열 구하기 (0) | 2021.08.20 |
[C#/COMMON] Type 클래스 : 자식 클래스 리스트 구하기 (0) | 2021.08.20 |
[C#/COMMON] 선행 0을 추가해 값 문자열 출력하기 (0) | 2021.08.20 |
[C#/COMMON] 최대 공약수를 사용해 정수 비율 구하기 (0) | 2021.08.20 |
[C#/COMMON] 최대 공약수 구하기 (0) | 2021.08.20 |
댓글을 달아 주세요