首页 > 解决方案 > 为什么 (Guid?)null ?? 默认返回空 guid

问题描述

VS 立即窗口的输出

default(Guid?)
=> null
(Guid?)null == default
=> true
(Guid?)null ?? default
=> {00000000-0000-0000-0000-000000000000}

我预计最后一个是null而不是Guid.Empty。那么为什么会这样呢?

标签: c#defaultguidnull-coalescing

解决方案


推荐阅读