chenpeng

C#二进制转换字符串
上一篇文章提到字符串转换二进制这篇文章介绍的二进制转换字符串 private string BinaryToStr...
扫描右侧二维码阅读全文
23
2019/07

C#二进制转换字符串

上一篇文章提到字符串转换二进制这篇文章介绍的二进制转换字符串

 private string BinaryToString(string str)
    {
        System.Text.RegularExpressions.CaptureCollection cs = System.Text.RegularExpressions.Regex.Match(str, @"([01]{8})+").Groups[1].Captures;
        byte[] data = new byte[cs.Count];
        for (int i = 0; i < cs.Count; i++)
        {
            data[i] = Convert.ToByte(cs[i].Value, 2);
        }
        return Encoding.Unicode.GetString(data, 0, data.Length);
    }
Last modification:July 23rd, 2019 at 04:32 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment