I need to write a if condition. It should enter the if condition only if all Nationalities in nationalities List [A,B,C] is available in separate List.
CASE 1 : If SeparateList contains[A,B,C,D,E] and if nationalities List contains [A,B,C], all values in nationalities List is avialable in SeparateList. Therefore it should satisfy 'if' condition.
CASE 2 :If SeparateList contains[A,C,D,E] and if nationalities List contains [A,B,C], B value in nationalities List is not avaIlable in SeparateList. Therefore it should not satisfy 'if' condition.
But currently my if condition is satisfying case 2. I think it is because of Intersect. So please suggest any ideas.
nationalities.Add(nation.ToUpper().Trim()); //contains list of nationalities [A,B,C]
if(nationalities.Intersect(separateList(bg.Nationality)).Any())
{
// code
}
private List<string> separateList(string input)
{
return input.ToUpper().Trim().Split(',').ToList();
}
Aucun commentaire:
Enregistrer un commentaire