首页 > Windows开发 > 详细

C# int to byte[] int 转 byte[]

时间:2020-01-02 12:36:41      阅读:73      评论:0      收藏:0      [点我收藏+]
 private static byte[] int2bytes(Int16 intValue)
        {
            byte[] intBytes = BitConverter.GetBytes(intValue);
            if (BitConverter.IsLittleEndian)
                Array.Reverse(intBytes);
            byte[] result = intBytes;
            return result;
        }

返回一个2位的byte

 private static byte[] int2bytes(Int32 intValue)
        {
            byte[] intBytes = BitConverter.GetBytes(intValue);
            if (BitConverter.IsLittleEndian)
                Array.Reverse(intBytes);
            byte[] result = intBytes;
            return result;
        }

返回一个4位的byte

C# int to byte[] int 转 byte[]

原文:https://www.cnblogs.com/z45281625/p/12131996.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!