zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    0593. Valid Square (M)
    0832. Flipping an Image (E)
    1026. Maximum Difference Between Node and Ancestor (M)
    0563. Binary Tree Tilt (E)
    0445. Add Two Numbers II (M)
    1283. Find the Smallest Divisor Given a Threshold (M)
    C Primer Plus note9
    C Primer Plus note8
    C Primer Plus note7
    C Primer Plus note6
  • 原文地址:https://www.cnblogs.com/LuoEast/p/10105888.html
Copyright © 2011-2022 走看看