I\'ve got a large text, containing a number as a binary value. e.g \'123\' would be \'001100010011001000110011\'. EDIT: should be 1111011
Now I want to convert it to
This'll do the trick:
public string BinToDec(string value) { // BigInteger can be found in the System.Numerics dll BigInteger res = 0; // I'm totally skipping error handling here foreach(char c in value) { res <<= 1; res += c == '1' ? 1 : 0; } return res.ToString(); }