How Does Resharper Know “Expression is always true”?

前端 未结 4 1401
既然无缘
既然无缘 2020-12-11 15:41

Check out the following code:

private void Foo(object bar)
{
   Type type = bar.GetType();

    if (type != null) // Expression is always true
    {   
    }         


        
4条回答
  •  失恋的感觉
    2020-12-11 16:18

    GetType is not virtual. Your assumption is most likely correct in your last statement.

    Edit: to answer your comment question - it can't infer with your methods out of the box.

提交回复
热议问题