.net - null 在 .NET 中如何表示

标签 .net memory null

我正在与一位同事交谈,并提出了 null 的主题。他告诉我,在幕后的 .NET 中,这只是一个非常小的数字。我一直认为对象只是没有指向堆上任何内存的指针,但我不确定这两种方式。

所以我希望社区可以为我们清除它;P

最佳答案

是 0。

从 ECMA-335 规范中的 ldnull 剪下:

It might be thought that ldnull is redundant: why not use ldc.i4.0 or ldc.i8.0 instead? The answer is that ldnull provides a size-agnostic null – analogous to an ldc.i instruction, which does not exist. However, even if CIL were to include an ldc.i instruction it would still benefit verification algorithms to retain the ldnull instruction because it makes type tracking easier.

关于.net - null 在 .NET 中如何表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/398966/

相关文章:

.net - Google Content API - 新版本

c# - 括号还是引号?

objective-c - 从数组中删除对象是否会运行对象的 dealloc 方法?

java - 不兼容类型 : int and <nulltype>

sql - Null是否大于任何日期数据类型?

.net - 自动将 CLR 数据库项目部署到数据库

c# - 使用 DeflateStream 读取与预期大小不匹配

java - Parent 变量如何存储大于 Parent 的 Child?

c++ - 使用 `memcpy()` 为指针分配地址

c# - 成员访问中的问号在 C# 中是什么意思?