我正在与一位同事交谈,并提出了 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/