【问题标题】:I'm looking for a way to convert char to bin array in C#我正在寻找一种在 C# 中将 char 转换为 bin 数组的方法
【发布时间】:2016-11-08 09:49:34
【问题描述】:

我正在尝试找到将 char 转换为位数组的方法,将其弄乱,然后将其转换回来。所有答案都是关于字符串到字节的。

【问题讨论】:

    标签: c# arrays char bit


    【解决方案1】:

    你的意思是BitArray

    如果是这样:

    char c = 'X';
    byte[] bytes = BitConverter.GetBytes(c);
    BitArray bits = new BitArray(bytes);
    

    【讨论】:

    • 这不像“gimmeh 代码”——我正在寻找一种方法,而不是某个特定的代码。像“使用方法 x”这样的答案就足够了。
    • @Areth 如果答案只是说“使用 BitConverter 和 BitArray”,它应该只是一个评论而不是一个答案 - 这就是 StackOverflow 的工作原理。
    • 亲爱的@Areth,“使用方法@MatthewWatson”;-)
    猜你喜欢
    • 2015-05-14
    • 2014-04-05
    • 1970-01-01
    • 2023-03-31
    • 2022-12-05
    • 2017-07-03
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多