二进制字符串转换为整数。 [英] Convert binary string into integer
本文介绍了二进制字符串转换为整数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想转换writen在一个字符串到其整数值二进制数。
I would like to convert a binary number writen in a String into its integer value.
例如:
string input = "0101";
int output = convert(input);
输出
应等于 5
编辑:这真是小巫见大巫有人问,因为我有另外的错误,在我的code不使我看到,皈依是不是我的问题。
This really trivial question was asked because I had another bug in my code not enabling me to see that the convertion was not my problem.
推荐答案
Convert.ToInt32(字符串,的Int32 )允许您指定的基地:
int output = Convert.ToInt32(input, 2);
这篇关于二进制字符串转换为整数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文