Please find my sample program below,
Condition 3 should not be true as per my inputs. But it returns true and statement inside if is getting executed. Help me to have better understanding of this.
static void Main(string[] args) {
string temp = null;
string temp1 = "0";
string temp2 = "1";
if (temp1 == "0" || temp2 == "2" && temp == null) {
Console.WriteLine("Contion 1 satisfied");
}
if (temp1 == "0" || temp2 == "1" && temp == null) {
Console.WriteLine("Contion 2 satisfied");
}
if (temp1 == "0" || temp2 == "1" && temp != null) {
Console.WriteLine("Contion 3 satisfied");
}
if (temp1 == "1" || temp2 == "1" && temp != null) {
Console.WriteLine("Contion 4 satisfied");
}
Console.ReadLine();
}
Thanks in advance