Unity_数据类型之间的相互转换
来源:互联网 发布:sql如何建立级联 编辑:程序博客网 时间:2024/06/06 14:49
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace CodeTest{ class Program { static void Main(string[] args) { //位bit 0,1 表示二进制文件的基础单位 //字节byte 八个0和1 (对位的封装) //基本类型float , int (4个字节), string ,ushort int a = 10;// 10 0 0 0 int b = 255;// 255 0 0 0 int c = 256;// 0 1 0 0 int c1 = 257;//1 1 0 0 int c2 = 265;//10 1 0 0 int d = 256 * 256;//0 0 1 0 //// int(4字节)(8位) Int32 //int e = 1 * 1 + 1 * 2 + 1 * 4 + 1 * 8 + 1 * 16 + 1 * 32 + 1 * 64 + 1 * 128; //Console.WriteLine(e); ////e==b; //int f = 0 * 1 + 0 * 2 + 0 * 4 + 0 * 8 + 0 * 16 + 0 * 32 + 0 * 64 + 0 * 128 + 1 * 256; //Console.WriteLine(c); ////f==c; //// (BitConverter)将基础数据类型与字节数组相互转换。 //byte[] bytes = BitConverter.GetBytes(c); //for (int i = 0; i < bytes.Length; i++) //{ // Console.WriteLine(bytes[i]); //} ////// shotr(2)(8) Int16 //ushort g = 10;// 10 0 //byte[] bytes = BitConverter.GetBytes(g); //for (int i = 0; i < bytes.Length; i++) //{ // Console.WriteLine(bytes[i]); //} ////转成不同类型会是不一样的结果; //int h = 256 * 256 * 256; //byte[] bytes = new byte[] { 0, 0, 1, 0 }; //short shortA = BitConverter.ToInt16(bytes,0); //Console.WriteLine(shortA);// 0 //int intA = BitConverter.ToInt32(bytes,0); //Console.WriteLine(intA);// 65536 //ushort ushortA = BitConverter.ToUInt16(bytes,0); //Console.WriteLine(ushortA);//0 //uint uintA = BitConverter.ToUInt32(bytes,0); //Console.WriteLine(uintA);//65536 } }}
阅读全文
0 0
- Unity_数据类型之间的相互转换
- 数据类型之间的相互转换
- VC数据类型之间的相互转换
- 实例:常用数据类型之间的相互转换
- Java数据类型之间的相互转换
- 基本数据类型之间的相互转换
- 数据类型之间可以相互转换
- Java 基本数据类型和Sting之间的相互转换
- C++各种数据类型之间的相互转换
- GO语言的一些简单数据类型之间相互转换
- objective-c中不同数据类型之间的相互转换
- 基本数据类型、包装类、String类型之间的相互转换
- MFC中常用数据类型之间的相互转换
- 数据类型之间的转换
- 数据类型之间的转换
- 数据类型之间的转换
- 数据类型之间的转换
- 数据类型之间的转换
- SQL Server 2017 SP1 补丁发布(二)
- 【阿里云】入门笔记-ECS云服务器配置java开发环境
- 动态规划:二维费用的背包问题
- 区域批量导入ocupload一键上传使用
- C++类和对象.四个默认成员函数(赋值运算符重载)
- Unity_数据类型之间的相互转换
- 51nod 1288 汽油补给【贪心】【ST表】【单调栈】
- Java面试题链表、树和位操作
- SQL Server 2017 SP1 补丁发布(三)
- 数据分析案例_2012联邦选举数据分析
- xampp安装、问题解决及使用
- Linux_1_文件——文件描述符
- 【本文由“编程大师”发布,2017年10月21日】
- implements和extends的区别