using System.Reflection;
using System.ComponentModel;
List<object> listZy = new List<object>();
var zyitem = new
{
xi = xi,
zy = zy,
unitid = "",
unitname = ""
};
listZy.Add(zyitem);
bool ishave=false;
foreach (var item in listZy)
{
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(item);
PropertyDescriptor pdID = pdc.Find("xi", true);
var x = pdID.GetValue(item);
PropertyDescriptor pdName = pdc.Find("zy", true);
var z = pdName.GetValue(item);
if (x.ToString() == xi && z.ToString() == zy)
{
ishave = true;
break;
}
}