The only reason i can see is that there's no element with name=="example"
and articleNumber=="1"
. Note that the ==
operator is case sensitive in C# and that there might be a white-space somewhere.
Then you can use this overload of Equals
to compare case-insensitive and remove white-spaces with Trim
:
if (!myList.Any( x => x.name.Trim().Equals("example", StringComparison.OrdinalIgnoreCase)
&& x.articleNumber == "1"))
{
}
else
{
}
You should also consider to change the type of articleNumber
to int
since it is a number.