32位windows下各数据类型在内存中占用的字节数
来源:互联网 发布:origin矩阵画图 编辑:程序博客网 时间:2024/06/06 07:08
测试系统: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 等占用的字节数是多少?
- 对SQL Server 2005应用TRY...CATCH回传事务
- 转:Oracle函数
- PHP Web服务的价值
- 自动定时开机,关机
- 正则表达式的实例应用
- 32位windows下各数据类型在内存中占用的字节数
- IT培训整体趋冷,高端培训热度不减
- 诺基亚拟1.53亿美元收购软件公司Trolltech
- this指针探秘
- tcp/ip网络协议栈分析博客
- 现代战争 使命
- 深入讲解数据库系统安全中的“漏洞发掘”
- 获取 $_SERVER["REQUEST_URI"] 值的通用解决方案
- 用PHP5进行三层开发