I have the following line of code below. Is there a method that can check team, DivisionTeam, Team, Coordinator, Profile, Address, and the last property StateRegion for null instead of doing it for every property?
if(team.DivisionTeam.Team.Coordinator.Profile.Address.StateRegion != null)
Currently in C#, you can’t, you have to individually check each property for null.
May be you are looking for “.?” operator, but its not there in C# 4.0, Check out this post and the response from Eric Lippert: Deep null checking, is there a better way?