We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

rengber on 03/27/07


Tagged

conversion


Versions (?)


Converting Integers To and From Binary


Published in: C# 


  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 

You need to login to post a comment.