C#Marshal.SizeOf [英] C# Marshal.SizeOf
本文介绍了C#Marshal.SizeOf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Marshal.SizeOf知道我的stucture大小:
I am using Marshal.SizeOf to know the size of my stucture:
struct loginStruct
{
public string userName;
public string password;
public loginStruct(string userName, string password)
{
this.userName = userName;
this.password = password;
}
}
下面是使用这个功能:
int len = Marshal.SizeOf(typeof(loginStruct));
我有2个节目。在一个程序len为等于8。在另一方面,它等于16
是相同的结构。为什么我得到的型差分?
I got 2 programs. In one program len is equals to 8. In the other it equals to 16. It is the same struct. Why I got that differece?
推荐答案
我猜一个程序被编译为值为anycpu(其中在64位平台将是64位),另一个用于32位。
I'd guess one program is compiled for AnyCPU (which on a 64-bit platform will be 64-bit) and one for 32-bit.
这篇关于C#Marshal.SizeOf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文