I assume that lgn
is null
, as usr
maye have returned the default value null
and assigned it to lgn
. Therefore you can check that lgn
is not null
:
if (lgn != null && !string.IsNullOrWhiteSpace(lgn.Email) {
user = lgn.Email;
}
user = "User not found/Email has not been set";