check value before assigning using ternary operator
// you can use below method to reduce null value exceptions while assigning value to variables
// check if value is available then assign value else asisgn default/empty value
if (mystring != null)
{
AnotherStringVarialble = mystring;
}
else
{
AnotherStringVarialble = String.Empty;
}
//or you can use below code instead
AnotherStringVarialble = (mystring != null) ? mystring : String.Empty ;