#region 检测一个对象的某个属性是不是等于某个值
private bool test(object c, string fieldName, string value)
{
foreach (System.Reflection.PropertyInfo p in c.GetType().GetProperties())
{
if (p.Name == fieldName)
{
if ((string)p.GetValue(c, null) == value)
{
return true;
}
else
return false;
}
}
return false;
}
#endregion
stockTradeOrderList = (from c in fastStockTradeOrderList
where test(c, sFieldName, tmp)
select c).ToList();
其中fastStockTradeOrderList是原有的List,stockTradeOrderList是筛选后的结果。两个List是同一个类的集合