C# Byte数组有符号无符号转换及对应表

摘要:
对应表:1规范指定了对应的代码解决方案publicstaticecimalFindValue(intdataType,byte[]temps){if(dataType==1){return(sbyte)temps[0];}elseif(dataType==2){returntemps[0],}elsief(dataType==3){shortaa=BitConverter.ToInt16(temps,0

对应表:

C# Byte数组有符号无符号转换及对应表第1张

1 规约规定

C# Byte数组有符号无符号转换及对应表第2张

 对应代码解法

 public static decimal FindValue(int dataType, byte[] temps)
        {
            if (dataType == 1)
            {
                return (sbyte)temps[0];
            }
            else if (dataType == 2)
            {
                return temps[0];
            }
            else if (dataType == 3)
            {
                short aa = BitConverter.ToInt16(temps, 0);
                return aa;
            }
            else if (dataType == 4)
            {
                ushort aa = BitConverter.ToUInt16(temps, 0);
                return aa;
            }
            else if (dataType == 5)
            {
                int aa = BitConverter.ToInt32(temps, 0);
                return aa;
            }
            else if (dataType == 6)
            {

                uint aa = BitConverter.ToUInt32(temps, 0);
                return aa;
            }
            else if (dataType == 7)
            {

                long aa = BitConverter.ToInt64(temps, 0);
                return aa;
                //valueLength = 8;
            }
            else if (dataType == 8)
            {

                ulong aa = BitConverter.ToUInt64(temps, 0);
                return aa;
            }
            else if (dataType == 9)
            {

                float aa = BitConverter.ToSingle(temps, 0);
                return (decimal)aa;
            }
            else if (dataType == 10)
            {

                double aa = BitConverter.ToDouble(temps, 0);
                return (decimal)aa;
            }

免责声明:文章转载自《C# Byte数组有符号无符号转换及对应表》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Manjaro 使用基础unity3D 重新加载场景时重置时间从0开始下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

swiper横向轮播(兼容IE8)

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <link rel="stylesheet"href="idangerous.swiper.cs...

轮播图3D效果--roundabout(兼容IE8)升级版

<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> *{ margin:0;...

Oracle 汉字转拼音

   --0 select fn_getpy('测试',0) from dual ceshi  --1 select fn_getpy('测试',1) from dual CESHI  --2 select fn_getpy('测试',1) from dual CeShi  --3 select fn_getpy('测试',3) from dual cs...

Ajax异步调用Controller的Return JsonResult生成下拉列表

1 @using System.Web.Optimization; 2 @{ 3 Layout = null; 4 } 5 6 <!DOCTYPE html> 7 8 <html> 9 <head> 10 <meta name="viewport" content="width...

ffmpeg 使用 gdb 调试相关技巧

本文说明了,在ffmpeg二次开发或调用库的过程,如何借助于ffmpeg源码进行调试。 注:ffmpeg版本是4.0。 1. 编写代码 编写将pcm数据转换为mp2的代码 pcm_to_mp2.c #include <libavformat/avformat.h> #include <libavcodec/avcodec.h> #i...

Vue.js 类型(数字、整数、小数、负数、手机号、座机号等)校验规则

Vue.prototype.validator = function (type) { switch (type) { case 'number': return /^(-|+)?d+(.d+)?$/;///^[0-9]*$/; case 'integer': retu...