I have data in which i'm getting
NullReferenceException : Object reference not set to an instance of an object
I know it has to do with an intentionally created attempt at making a null in a list. I'm using linqpad to try and mimic my code
List<string> list = new List<string>();
list.Add(null);
list.Add("scorp\\jack");
list.Add("you");
var x = "jack";
var admin = 0;
foreach (var y in list) // Loop through List with foreach.
{
    //Console.WriteLine(prime);
    if(y.Contains(x))
    {
        admin = 1;
    }
}
Console.WriteLine(admin);
As soon as it runs over
 if(y.Contains(x)) 
Then it cannot handle the null and I wonder what graceful way of handling it would be?
 
    