Maha

Maha

  • NA
  • 0
  • 325.9k

Converting

Oct 23 2013 5:21 AM
When Converting decimal to binary or binary to decimal following function has been used.

binaryNum = Convert.ToString(decimalNum, 2);
i = Convert.ToInt32(binaryString, 2);

I wish to know what is 2 means. Problem is highlighted below.

using System;

namespace Converting_decimal_binary
{
class Program
{
static void Main(string[] args)
{
//Converting decimal to binary
int decimalNum = 20;
string binaryNum = Convert.ToString(decimalNum, 2);//10100
Console.WriteLine(binaryNum);

//Converting binary to decimal
//where binaryString is the binary number expressed as a string.
string binaryString = "10100";
int i = Convert.ToInt32(binaryString, 2);
Console.WriteLine(i);//20

Console.ReadKey();
}
}
}


Answers (4)