zoukankan      html  css  js  c++  java
  • C# 数据类型转化为byte数组

    short数据与byte数组互转

    public byte[] ShortToByte(short value)
        {
            return BitConverter.GetBytes(value);
        }
        public short ByteToShort(byte[] arr)
        {
            return BitConverter.ToInt16(arr,0);
        }

    string数据与byte数组互转

    public byte[] StringToByte(string value)
    {
        return  Encoding.UTF8.GetBytes(value);
        //return Text.Encoding.Default.GetBytes (value);
    }
    public string ByteToString(byte[] arr)
    {
        return Encoding.UTF8.GetString(arr);
        //return Text.Encoding.UTF8.GetString (arr, 0, arr.Length);
    }

    int数据与byte数组互转

    public byte[] IntToByte(short value)
       {
           return BitConverter.GetBytes(value);
       }
        public int ByteToInt(byte[] arr)
       {
           return BitConverter.ToInt32(arr,0);
       }
    萌橙 你瞅啥?
  • 相关阅读:
    JS 按钮下一步(onclick点击事件)
    socketserver模块
    进程
    僵尸进程和孤儿进程
    守护进程
    互斥锁
    进程间通信=>IPC机制
    生产者消费者模型
    线程
    守护线程
  • 原文地址:https://www.cnblogs.com/daimaxuejia/p/11942943.html
Copyright © 2011-2022 走看看