Q:

Find Any string contains List<>

I'm trying to find a string from the List....seems like its not working and if I have just List<string> it does work.. meaning like the below code...
    List<string> c = new List<string>();
    c.Add("John Doe"));
    c.Add("Erich Schulz"));

//I think the problem with the Criterion class?
here is my class structure:
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;
}

here is the code I'm trying to make it work:
bool isExists = LoadNames.Any(s=> "Erich Schulz".Contains(s));

Error:
does not contain a definition for 'Any' and the best extension method overload 'System.Linq.Enumerable.Any<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,bool>)' has some invalid arguments 

A:

You're attempting to compare a string to a Criterion object, which just doesn't work.
Here is the fixed code:
bool isExists = LoadNames.Any(criterion => String.Equals(criterion.PropertyName, "Erich Schulz", StringComparison.OrdinalIgnoreCase));

