C# 截取 byte 字节 转字符串

  byte[] byteArray = System.Text.Encoding.Default.GetBytes(content);

Byte[] ThisByte = new Byte[1];
Buffer.BlockCopy(byteArray, 30, ThisByte, 0, 1);
string str=Encoding.Default.GetString(ThisByte);

 

 

 

 

 

 //
        // 摘要:
        //     将指定数目的字节从起始于特定偏移量的源数组复制到起始于特定偏移量的目标数组。
        //
        // 参数:
        //   src:
        //     源缓冲区。
        //
        //   srcOffset:
        //     src 中从零开始的字节偏移量。
        //
        //   dst:
        //     目标缓冲区。
        //
        //   dstOffset:
        //     dst 中从零开始的字节偏移量。
        //
        //   count:
        //     要复制的字节数。
        //
        // 异常:
        //   T:System.ArgumentNullException:
        //     src 或 dst 为 null。
        //
        //   T:System.ArgumentException:
        //     src 或 dst 不是基元数组。- 或 -src 的长度小于 srcOffset 加上 count。- 或 -dst 的长度小于 dstOffset 加上
        //     count。
        //
        //   T:System.ArgumentOutOfRangeException:
        //     srcOffset、dstOffset 或 count 小于 0。
        [SecuritySafeCritical]
        public static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count);

转载于:https://www.cnblogs.com/LuoEast/p/10105888.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值