【发布时间】:2011-04-13 04:54:32
【问题描述】:
我通过反射检查对象的属性并继续处理每个属性的数据类型。这是我的(简化的)来源:
private void ExamineObject(object o)
{
Type type = default(Type);
Type propertyType = default(Type);
PropertyInfo[] propertyInfo = null;
type = o.GetType();
propertyInfo = type.GetProperties(BindingFlags.GetProperty |
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance);
// Loop over all properties
for (int propertyInfoIndex = 0; propertyInfoIndex <= propertyInfo.Length - 1; propertyInfoIndex++)
{
propertyType = propertyInfo[propertyInfoIndex].PropertyType;
}
}
我的问题是,我最近需要处理可空属性,但我不知道如何获取可空属性的类型。
【问题讨论】:
-
我找到了很好的答案here值得一试!!
标签: c# .net reflection nullable