【发布时间】:2014-03-25 08:44:17
【问题描述】:
我有课
namespace MyNamespace1
{
class MyClass
{
public string MyName { get; set; }
public int? MaxHeaderLength { get; set; }
public System.Collections.Generic.List<MyClass.ViewModel> Preferences { get; set; }
}
}
namespace MyNamespace2
{
internal class myClass1
{
public static void Main(string[] args)
{
var properties = loading assembly of the MyClass of MyNamespace1
var prop = properties.GetProperties();
foreach (var propertyInfo in prop)
{
Console.WriteLine(propertyInfo.PropertyType.FullName);
}
}
}
}
当我想在运行时使用反射读取属性时
我得到的类型为
System.String,
System.Nullable`1[[System.Int32, mscorlib, 版本=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
System.Collections.Generic.List`1[[System.Web.Mvc.SelectListItem, System.Web.Mvc,版本=3.0.0.0,文化=中性, PublicKeyToken=31bf3856ad364e35]]),
但我想检索为
string,
int?,
System.Collections.Generic.List<MyClass.ViewModel>
谁能给我解决方案。
【问题讨论】:
标签: c# system.reflection