Showing posts with label Binary. Show all posts
Showing posts with label Binary. Show all posts

Wednesday, December 19, 2012

C# Convert Decimal to Binary and Vice Versa

Decimal to Binary conversion as below:
 
int DecimalVal = 256;
string BinaryVal = Convert.ToString(DecimalVal, 2);
Binary to Decimal conversion as below:
 
string BinaryVal = "01001101";
string DecimalVal = Convert.ToInt32(BinaryVal, 2).ToString();