c# - Concatenate binaries then convert to int -


string middlepart = "1111"; string leftpart = "0000"; string rightpart = "0000"; 

i want concatenate 3 of these make 000011110000, , convert binary int.

the code below not work because number way big.

int maskingval = convert.tobyte((leftpart+middlepart+rightpart), 2); 

is there way convert.tobyte on each individual part of binary int, , concatenate binary equivalent correct int value of 000011110000.

thank you

i don't know why not do

var maskingval = convert.toint16((leftpart + middlepart + rightpart), 2); 

but can way too

byte middlepart = convert.tobyte("1111", 2); byte leftpart = convert.tobyte("0000",2); byte rightpart = convert.tobyte("0000",2);  var maskingval = leftpart << 8 | middlepart << 4 | rightpart; 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -