首页 新闻 会员 周边

关于C# Lazy<T> 源码的一个问题

0
[待解决问题]
 1     [DebuggerBrowsable(DebuggerBrowsableState.Never)]
 2     [__DynamicallyInvokable]
 3     public T Value
 4     {
 5       [__DynamicallyInvokable] get
 6       {
 7         if (this.m_boxed != null)
 8         {
 9           Lazy<T>.Boxed boxed = this.m_boxed as Lazy<T>.Boxed;
10           if (boxed != null)
11             return boxed.m_value;
12           (this.m_boxed as Lazy<T>.LazyInternalExceptionHolder).m_edi.Throw();
13         }
14         Debugger.NotifyOfCrossThreadDependency();
15         return this.LazyInitValue();
16       }
17     }

 

既然在第7行已经判断了m_boxed非空,为什么第10行的判断语句还要再判断一次?

我妻黑猫的主页 我妻黑猫 | 菜鸟二级 | 园豆:204
提问于:2018-03-11 20:48
< >
分享
所有回答(1)
0

第9行是转换类型,之后在判断是否为空

华临天下 | 园豆:1501 (小虾三级) | 2018-03-12 10:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册