📜  将字符串转换为位 c# - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:21.391000             🧑  作者: Mango

代码示例1
string str = "1000111"; //this is your string in bits
        byte[] bytes = new byte[str.Length / 7];
        int j = 0;
        while (str.Length > 0)
        {
            var result = Convert.ToByte(str.Substring(0, 7), 2);
            bytes[j++] = result;
            if (str.Length >= 7)
                str = str.Substring(7);
        }
        var resultString = Encoding.UTF8.GetString(bytes);