Converting a binairy to decimal is easy:
long l = Convert.ToInt64(txtMBBS.Text, 2);
int i = (int)l;
converting a decimal to a binairy can be a litlle bit harder:
public static string ToBinary(Int64 Decimal)
{
// Declare a few variables we're going to need
Int64 BinaryHolder;
char[] BinaryArray;
string BinaryResult = "";
while (Decimal > 0)
{
BinaryHolder = Decimal % 2;
BinaryResult += BinaryHolder;
Decimal = Decimal / 2;
}
// The algoritm gives us the binary number in reverse order (mirrored)
// We store it in an array so that we can reverse it back to normal
BinaryArray = BinaryResult.ToCharArray();
Array.Reverse(BinaryArray);
BinaryResult = new string(BinaryArray);
return BinaryResult;
}
Found this function on this site: http://kyrathaba.dcmembers.com/errata/binary_decimal.htm