Converting Integers To and From Binary


/ Published in: C#
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //To Binary from Integer
  2. int startVal = 7;
  3. int base = 2;
  4. string binary = Convert.ToString(startVal, base);
  5.  
  6. //To Integer From Binary
  7. string binary = "111";
  8. int base = 2;
  9. int integer = Convert.ToInt32(binary, base);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.