リストから文字列を見つけようとしています....機能していないList<string>
ようです..
List<string> c = new List<string>();
c.Add("John Doe"));
c.Add("Erich Schulz"));
// Criterion クラスに問題があると思いますか? ここに私のクラス構造があります:
public class Criterion
{
public Criterion(String propertyName, object value)
{
this.PropertyName = propertyName;
this.Value = value;
}
}
//here is the method...
public static List<Criterion> LoadNames()
{
List<Criterion> c = new List<Criterion>();
c.Add(new Criterion("Name1", "John Doe"));
c.Add(new Criterion("Name2", "Erich Schulz"));
return c;
}
これを機能させようとしているコードは次のとおりです。
bool isExists = LoadNames.Any(s=> "Erich Schulz".Contains(s));
エラー:
「Any」の定義と最適な拡張メソッドのオーバーロードが含まれていません'System.Linq.Enumerable.Any<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,bool>)' has some invalid arguments