The below code snippet shows how .NET evaluates expressions in if statement.
-------------------------------
string x = null;
if (!string.IsNullOrEmpty(x) && x.ToString().Equals(""))
Console.WriteLine("True");
else
Console.WriteLine("False");
if (string.IsNullOrEmpty(x) || x.ToString().Equals(""))
Console.WriteLine("True");
else
Console.WriteLine("False");
-------------------------------
Output:
False
True
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment