Is there any harm in safeguard?

When using events and the Invoke(), is there any harm in safeguarding it with the ‘?’


Does it cost more performance ?

I use it everywhere.
This is what is called null propogation, a form of syntactic sugar. The compiler actually expands this to


What this means is that you don’t need to surround onHit?.Invoke(); with a null checking block.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms