I am facing a problem in dealing with basic if else statement in C#.
I have two variables of type uint. I need to check whether the first variable is in the range of the second one. Also, the first variable can have value null. The output comes up fine in case of i put some value for the first value. But the desired output fails in case I put null in the first variable
I did it in this manner.
using System;
public class Test
{
public static void Main()
{
uint var1 = 0x00000000;
uint var2 = 0x0ffffffa;
if (!((var1 == null) || (((var1 != null) && (var1 & var2)) > 0)))
Console.WriteLine ("no");
else
Console.WriteLine ("yes");
}
}
The code when the output is coming as no is :
using System;
public class Test
{
public static void Main()
{
uint var1 = 0x00000000;
uint var2 = 0x0ffffffa;
if (!(((var1 != null) && ((var1 & var2) > 0)) || (var1 == null)))
Console.WriteLine ("no");
else
Console.WriteLine ("yes");
}
}
But the output is coming as "no". Where am I going wrong?
I want a 'yes' as an output. I need to check for the first variable. If it is null then fine, if not, then whether it is in the range of the second variable, if it is, then also fine