ReSharper: how to remove “Possible 'System.NullReferenceException'” warning

后端 未结 6 1944
长情又很酷
长情又很酷 2020-12-11 02:41

Here is a piece of code:

IUser user = managerUser.GetUserById(UserId);
if ( user==null ) 
    throw new Exception(...);

Quote quote = new Quote(user.FullNam         


        
6条回答
  •  北海茫月
    2020-12-11 03:37

    Q1: Because Resharper doesn't do path analysing. It just sees a possible null reference and flags that.

    Q2: You can't without doing either of what you provided already.

提交回复
热议问题