原文:c# 确定dynamic类型的数据对象是否存在某个属性
public static bool IsPropertyExist(dynamic data, string propertyname)
{
if (data is ExpandoObject)
return ((IDictionary<string, object>)data).ContainsKey(propertyname);
return data.GetType().GetProperty(propertyname) != null;
}
原文地址:https://www.cnblogs.com/lonelyxmas/p/11286847.html
时间: 2024-11-10 13:36:56