【发布时间】:2016-07-22 08:10:06
【问题描述】:
我想知道他们究竟是如何从 C#/.NET 中的布尔类型生成哈希码的?
【问题讨论】:
-
简单。如果值为
true,则hashcode为1,如果值为false,则hashcode为0。 -
@Dennis_E 类似:“return bool ? 1 : 0;”
-
没错。但在源码中,1 和 0 被定义为常量。 referencesource.microsoft.com/#mscorlib/system/…
标签: c# boolean gethashcode