标签: c# .net
这是如何从十进制转换为二进制:
int dec = 42; string bin = Convert.ToString(dec, 2);
如果我有
string bin = "0100101" int dec = ???
答案 0 :(得分:7)
只需查看反向通话 - Convert.ToInt32(value, fromBase):
Convert.ToInt32(value, fromBase)
int dec = Convert.ToInt32(bin, 2);