我想编写一个扩展方法来过滤所有在人员对象中具有城镇的人以及商店对象中的城镇
class people
string name
string town
class shops
string category
string town
我知道我会写
var x = from p in people
from s in shops
where p.town == s.town
但我想知道怎么写
var x = from p in people.FilterByTown(p) or FilterByTown(p => p.town) or however it is!!
其中 FilterByTown 是扩展方法,所有的魔法都在那里工作,我传入的对象与商店对象进行比较。
它需要处理被提供给方法的不同对象
希望一切都说得通,上面的代码显然是伪代码!