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
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.
I've just heard that grey codes in VS will still be compiled. The null check is still effective. So this is not a problem at all.
IDE makes it grey to suggest that there's simpler formats, which is the null condition operator in my case. However it should not give such suggestion here, just ignore it would be fine.