I have a list as follows,
List<string> variablelist = new List<string> { "first", "second","third"};
And i have one more list, like
List<string> method = new List<string>();
//somecode
method.Add(workingline);
I want to check if any of the element of variablelist
is NOT present in method
list and also I want get that Particular ELEMENT.
Thanks in Advance
LINQ is the simplest way of doing this, with the Except
method:
var inOnlyVariableList = variableList.Except(method).ToList();
The result will be a List<string>
of strings which are in variableList
but not in method
.
See more on this question at Stackoverflow