Greyed out my codes of null checking before invoking a delegate

前端 未结 2 887
北荒
北荒 2021-01-25 04:29

I write unity codes in VS 2015, which means it\'s in c#4 and the null condition operator is not available.

Before invoking a delegate, I did a null check. However the co

2条回答
  •  耶瑟儿~
    2021-01-25 04:58

    Before invoking a delegate, I did a null check. However the codes are greyed out. Does it mean the grey codes are not effective just like comments?

    It means that the Visual Studio pre-compiler/design-time-compiler detects the statement is most likely not needed.

    If so what should I do to prevent invoking a null delegate?

    Nothing, the compiler will still determine at compile time (and actually at run-time as well) if the statement is needed.

提交回复
热议问题