public static object decode(string inString) { var result = 0; var negative = false; var shift = 0; for (var i = 0; i < inString.Length; i++) { var thebyte = Base64Format.decodeChar(inString.Substring(i, 1)); if (i == 0) { // Sign bit appears in the LSBit of the first value if ((thebyte & 1) == 1) { negative = true; } result = (thebyte >> 1) & 15; // 1111x } else { result = result | ((thebyte & 31) << shift); // 11111 } shift += (i == 0) ? 4 : 5; if ((thebyte & 32) == 32) { // Continue } else { return(new { value = negative ? -(result) : result, rest = inString.Substring(i + 1) }); } } //throw new Error(getDiagnosticMessage(DiagnosticCode.Base64_value_0_finished_with_a_continuation_bit, [inString])); throw new Exception("Base64 value 0 finished with a continuation bit"); }