我想创建一个基本程序,使我能够将二进制数转换为十进制数,但是在互联网上几乎无处不在,我只是找不到可行的解决方案!我似乎无法遵循解决方案,到目前为止,我已经开发了一些代码,但不确定它是否正确,有什么帮助吗?谢谢
int iBinaryNum; //To store binary number
string sDecimalNum; //To store decimal numbers
Console.WriteLine("Enter the binary number you want to convert to decimal");
iBinaryNum = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("The Binary number you have entered is " + iBinaryNum);
sDecimalNum = Convert.ToString(iBinaryNum, 2);
Console.WriteLine("This converted into decimal is " + sDecimalNum);
//Prevent program from closing
Console.WriteLine("Press any key to close");
Console.ReadKey();