Sunday, 15 January 2012

winforms - Get 8 digit binary from char in c# win. form -



winforms - Get 8 digit binary from char in c# win. form -

how 8 digit binary char in c# win. form?

like if write d should homecoming 01000100 , if write t should homecoming 01010100

char c = 'd'; string s = convert.tostring(c,2); // results in "1000100" string s2 = s.padleft(8, '0'); // results in "01000100"

op asked faster solution, suggest pre-calculated lookup table

string[] binaries = new string[256]; // calulate 8 bit decimal string representations. // once, on initialization. for(int = 0; < 256; i++) { binaries[i] = convert.tostring(i,2).padleft(8, '0'); } // representation character. char c = 'd'; string s = binaries[c];

c# winforms binary

No comments:

Post a Comment