为什么赢了';这个二进制到十进制的转换器在c#工作吗?

为什么赢了';这个二进制到十进制的转换器在c#工作吗?,c#,binary,decimal,converter,C#,Binary,Decimal,Converter,好吧,在其他问题和谷歌上找到了大量的解决方案,我似乎找不到这个问题的解决方案。。这是我的代码,感谢您的帮助,这让我发疯,谢谢 int iBinaryNum; //To store binary number string sDecimalNum; //To store decimal numbers Console.WriteLine("Enter the binary number you want to convert to

好吧,在其他问题和谷歌上找到了大量的解决方案,我似乎找不到这个问题的解决方案。。这是我的代码,感谢您的帮助,这让我发疯,谢谢

           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();

你搞错了

    static void Main(string[] args)
    {
        string sBinaryNum; //To store binary number
        int iDecimalNum; //To store decimal numbers

        Console.WriteLine("Enter the binary number you want to convert to decimal");
        sBinaryNum = Console.ReadLine();

        Console.WriteLine("The Binary number you have entered is " + sBinaryNum);


        iDecimalNum = Convert.ToInt32(sBinaryNum, 2);

        Console.WriteLine("This converted into decimal is " + iDecimalNum);

        //Prevent program from closing
        Console.WriteLine("Press any key to close");
        Console.ReadKey();
    }

我看不到任何关于你问题的描述。怎么了?如果我没弄错的话,你就换成另一种方式!试着输入
8
看看,如果它输出
100
它不会将二进制数转换成十进制数,它只会显示一个由0和1组成的奇怪数字,你知道如何修复吗?抱歉这么简单。你一小时前问过这个问题!!!这里:@EugenRieck是的,它输出了1000,所以我看到这是8的二进制,真可惜,你确定没有办法这样转换吗?多年来我一直在努力解决这个问题,谢谢!我没有意识到它是如此简单,我甚至没有意识到我有相反的方法,直到eugen rieck在上面指出,我现在就尝试一下,但不明白为什么它不起作用,非常感谢!)如果他的回答对你有帮助的话,就接受他。是的,我会这样做:)现在不让我,剩下6分钟说