这个 C# 结构的大小是多少? [英] What's the size of this C# struct?

查看:30
本文介绍了这个 C# 结构的大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存储在List中是12字节还是16字节?

Is it 12 bytes or 16 bytes when stored in a List<DataPoint>?

public struct DataPoint
{
    DateTime time_utc;
    float value;
}

C#中是否有sizeof函数?

Is there any sizeof function in C#?

推荐答案

看看@Hans Passant 的回答 此处 有关此问题的有趣背景,尤其是.关于Marshal.Sizeof的限制.

Take a look at @Hans Passant's answer here for interesting background on this issue, esp. with regard to the limitations of Marshal.Sizeof.

这篇关于这个 C# 结构的大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆