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)
LDW
  • 2,282
  • 18
  • 24

0 Answers0