📜  c# 获取列表的属性类型 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:49.901000             🧑  作者: Mango

代码示例1
var obj = new PropClassDemo();
foreach (PropertyInfo prop in obj.GetType().GetProperties())
{
    if(prop.PropertyType != typeof(string) && typeof(IEnumerable).IsAssignableFrom(prop.PropertyType))
    {
        Console.Writeline("This prop's type is Ienumerable");
    }
}

//Note: string is an ienumerable too