Maybe I'm doing it wrong, but
I have a list of objects in LINQ;
MyObj
string name
string somethingElse
List<MyObj> myObjects;
Now I'm trying to see if any object in this list has a string value;
So, I have a:
if (Model.myObjects.Contains("thisobject", new MyObjComparer()))
{
}
In comparison, I have:
public class MyObjComparer: IEqualityComparer<MyObj>
{
public bool Equals(string containsString, MyObj obj)
{
return obj.name == containsString;
}
}
How to use matching to check string value in objects field?
source
share