c# - Validating an if-condition with bitwise operators -


i facing problem in dealing basic if else statement in c#.

i have 2 variables of type uint. need check whether first variable in range of second one. also, first variable can have value null. output comes fine in case of put value first value. desired output fails in case put null in first variable

i did in 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 output coming no :

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 output coming "no". going wrong?

i want 'yes' output. need check first variable. if null fine, if not, whether in range of second variable, if is, fine

i'm confused question here. you've initialized variables, can't null, you've used or logical operand statement short-circuit when evaluates first term , finds true.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -