【发布时间】:2012-06-21 00:25:51
【问题描述】:
我有一个这样的参数列表:
public class parameter
{
public string name {get; set;}
public string paramtype {get; set;}
public string source {get; set;}
}
IEnumerable<Parameter> parameters;
还有一个我想检查的字符串数组。
string[] myStrings = new string[] { "one", "two"};
我想遍历参数列表并检查源属性是否等于任何 myStrings 数组。我可以用嵌套的 foreach 来做到这一点,但我想学习如何以更好的方式做到这一点,因为我一直在玩 linq 并且喜欢可枚举的扩展方法,比如 where 等,所以嵌套的 foreach 感觉不对。是否有更优雅的首选 linq/lambda/delete 方式来执行此操作。
谢谢
【问题讨论】:
标签: c# list loops c#-4.0 subset