0

If I do:

var a = FirstPossibleNull.SecondPossibleNull.ThirdPossibleNull.FourthPossibleNullValue;

I'd have to check if "FirstPossibleNull" and "SecondPossibleNull" and 'ThirdPossibleNull" is not null to avoid running in a potential error.

Is there a more elegant (and shorter) solution than this sort of check:

if (FirstPossibleNull != null && FirstPossibleNull.SecondPossibleNull != null && FirstPossibleNull.SecondPossibleNull.ThirdPossibleNull != null)
BTC
  • 2,975
  • 1
  • 19
  • 25

0 Answers0