【发布时间】:2016-02-02 12:30:19
【问题描述】:
KeyValuePair<int, int>: 8 bytes
KeyValuePair<long, long>: 16 bytes
KeyValuePair<long, int>: 16 bytes (!!)
KeyValuePair<int, long>: 16 bytes (!!)
我希望后两对只需要 8 (long) + 4 (int) = 12 个字节。为什么要占用 16 个?
大小是使用通过 ILGenerator 发出的动态 SizeOf 确定的,如下所述:Size of generic structure
【问题讨论】:
-
@PetSerAl 我得到了相同的结果,所以我对这两种情况都很好奇。
标签: c# struct sizeof keyvaluepair