I have a list as follows:
public class Emp
{
public string? Name {get;set;}
public int? Id {get;set;}
}
I have a list as:
List<Emp> empList = new List<Emp>();
The input for the list is:
{"A",null}
{null,null}
I want to check if Name in the list has value for atleast for one object. In this case , since "A" is present I should get true. Similarly If I ask for ID , I should get false because both are null.
I tried this: Edit:
if(empList.Any(x=> x.Name != null))
I get an error:
"Expression cannot contain lambda expressions"
How do I check it?
Edit: Making the property as nullable