What is the opposite of ‘Contains’ in C#?
You haven’t quite mentioned the context of your question, for making a guess here.
Easiest way to check if “not” contains would be to use negation operator !. For example,
!
To check to ensure does not contain a particular substringif(!str.Contains(substring))To ensure a particular item is not part of collection
if(!str.Contains(substring))
if(!list.Contains(item))
I find the question pretty confusing if not silly.
you can use not operator for check enter value is not in list .
if (!myList.Contains("name")){ myList.Add("name");}
if (!myList.Contains("name"))
{
myList.Add("name");
}
or you can use any method to perform same.
if (!myList.Any(s => s == "name")){ myList.Add("name");}
if (!myList.Any(s => s == "name"))
you can use Except in case of list types
Use ! operator