日期:2014-05-17 浏览次数:20748 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Console_File
{
class Program
{
static void Main(string[] args)
{
Info o = new Info();
int buff_size = 0;
int a = Marshal.SizeOf(o.A);
int b = Marshal.SizeOf(o.B);
int c = Marshal.SizeOf(o.C);
int d = SizeOf(bool);
buff_size = a + b + c;
Console.WriteLine("int Marshal.SizeOf:" + a);
Console.WriteLine("bool Marshal.SizeOf:" + b);
Console.WriteLine(c);
Console.WriteLine(buff_size);
Console.WriteLine("bool SizeOf:" + d);
// 要用此方法创建文件
//FileStream fs = new FileStream(filename, mode, access, share, 1, options);
Console.Read();
}
private class Info
{
public int A;
public bool B;
public Object C;
}
}
}