我如何制作可以存储数据类型(例如字符串,日期时间,十进制等)的集合?然后使用该集合进行比较:
if (pi.PropertyType.IsIn ([how can check against the collection of type) //where pi is a property info]))
{
}
有什么建议么?
最佳答案
List<Type> types = new List<Type> {typeof(string), typeof(int)};
if (types.Contains(pi.PropertyType))
{
//do stuff
}