【发布时间】:2013-11-28 13:05:40
【问题描述】:
例如我有以下代码
public class Person
{
public bool FirstNameIsActive { get; set; }
public bool SecondNameIsActive { get; set; }
}
如果我想按属性过滤FirstNameIsActive
Func<Person, bool> predicate1 = x => x.FirstNameIsActive == true;
如果我想按属性过滤SecondNameIsActive
Func<Person, bool> predicate2 = x => x.SecondNameIsActive == true;
我想在运行时将我的谓词更改为
Func<Person, bool> predicate = x => x.PropertyThatIWant == true;
【问题讨论】:
标签: c# .net lambda expression func