It looks like you want test != null && test.Contains("mystring")
Your assignment question does not make sense. All expressions, including the conditional operator, must have a value. What would you expect this expression to evaluate if test is null?
You probably want this to be false if the test is null.
In other words, you want this to be true if the test is not null and contains mystring .
SLaks source share