32位windows下各数据类型在内存中占用的字节数
来源:互联网 发布:vb窗体控件 编辑:程序博客网 时间:2024/06/06 17:17
测试系统:Windows2003 server
C#中测试的结果:
int:4bytes;
Int16:2bytes;
Int32:4bytes;
Int64:8bytes;
byte:1bytes;
bool:1bytes;
Single:4bytes;
decimal:16bytes;
double:8bytes;
char:2bytes;
DateTime:8bytes;
float:4bytes;
Guid:16bytes;
long:8bytes;
UIntPtr:4bytes;
uint:4bytes;
UInt16:2bytes;
UInt32:4bytes;
UInt64:8bytes;
ulong:8bytes;
C#测试的代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
struct display
{
public string paramType;
public int size;
}
class Program
{
static void Main(string[] args)
{
unsafe
{
display[] sizes = new display[20];
sizes[0].size = sizeof(int);
sizes[0].paramType = "int";
sizes[1].size = sizeof(Int16);
sizes[1].paramType = "Int16";
sizes[2].size = sizeof(Int32);
sizes[2].paramType = "Int32";
sizes[3].size = sizeof(Int64);
sizes[3].paramType = "Int64";
sizes[4].size = sizeof(byte);
sizes[4].paramType = "byte";
sizes[5].size = sizeof(bool);
sizes[5].paramType = "bool";
sizes[6].size = sizeof(Single);
sizes[6].paramType = "Single";
sizes[7].size = sizeof(decimal);
sizes[7].paramType = "decimal";
sizes[8].size = sizeof(double);
sizes[8].paramType = "double";
sizes[9].size = sizeof(char);
sizes[9].paramType = "char";
sizes[10].size = sizeof(DateTime);
sizes[10].paramType = "DateTime";
sizes[11].size = sizeof(float);
sizes[11].paramType = "float";
sizes[12].size = sizeof(Guid);
sizes[12].paramType = "Guid";
sizes[13].size = sizeof(long);
sizes[13].paramType = "long";
sizes[14].size = sizeof(UIntPtr);
sizes[14].paramType = "UIntPtr";
sizes[15].size = sizeof(uint);
sizes[15].paramType = "uint";
sizes[16].size = sizeof(UInt16);
sizes[16].paramType = "UInt16";
sizes[17].size = sizeof(UInt32);
sizes[17].paramType = "UInt32";
sizes[18].size = sizeof(UInt64);
sizes[18].paramType = "UInt64";
sizes[19].size = sizeof(ulong);
sizes[19].paramType = "ulong";
StreamWriter sw = new StreamWriter(@"D:/1.txt", true, Encoding.UTF8);
sw.WriteLine("========================================================================");
sw.WriteLine(" size of each type ");
sw.WriteLine("========================================================================");
foreach (display temp in sizes)
{
if (temp.paramType != null)
sw.WriteLine(temp.paramType + ":" + temp.size.ToString() + "bytes;");
}
bool booltest = true;
sw.WriteLine("bool is true:"+booltest.ToString());
booltest = false;
sw.WriteLine("bool is false:" + booltest.ToString());
sw.Close();
Console.Read();
}
}
}
}
- 32位windows下各数据类型在内存中占用的字节数
- 32位windows下各数据类型在内存中占用的字节数
- c#中数据类型占用的字节数
- C语言中结构体和共同体在内存中占用字节数
- C/C++32位与64位数据类型占用的字节数
- 单片机中各个数据类型在内存中占的字节数
- sizeof运算符来获取各种数据类型在内存中所占字节数--gyy整理
- 在32位、64位操作系统下各数据类型所占的字节数
- 在32位、64位操作系统下各数据类型所占的字节数
- 图片在内存中占用的大小
- Windows下数据类型的字节数
- c语言基本数据类型在内存中所占字节
- Oracle中number数据类型所占用的字节数
- Oracle中number数据类型所占用的字节数
- C中 各个数据类型占用的字节数
- windows下在内存中运行程序
- 各类数据的精度、数值范围和在内存中所占的字节数。
- 16位 32位 64位下 int double short long char 等占用的字节数是多少?
- Linux内存释放机制
- 使用UIActivityIndicatorView
- android 开发中的Log
- Vim正则表达式整理
- MFC 8: I'm Not Dead Yet
- 32位windows下各数据类型在内存中占用的字节数
- linux环境有关编程(2)
- Android APK应用安装原理(2)-查找APK并自动安装
- GoogleAndroid常用的Android常量
- intent 组件
- js 不能提交或重置表单,提示reset或submit方法不存在
- 第七章:时间、延迟及延缓操作
- 如何实现windows与虚拟机linux下的文件共享
- Java实现CSV读写操作源代码