I'm making a method call which takes the results of another four method calls as parameters--but the methods making those calls may or may not be null (sorry if that's a hopelessly unintelligible sentence). Here's the code, if it makes things clearer:
public void Inform(Room north, Room south, Room east, Room west)
{
this.north = north;
this.south = south;
this.east = east;
this.west = west;
node.Inform(north.GetNode(), south.GetNode(),
east.GetNode(), west.GetNode());
}
Basically, I want to know if there's a quick and easy way to check if an object is null and simply pass 'null' into the method besides conditionals--I'd rather not have to explicitly code for all 16 possible variations of null/not null.
EDIT: In response to confusion, I want to clarify this: most of the time the objects I'm passing into the method won't be null. Usually, Room
objects exist for north, south, east, and west, and if the Room
exists, the GetNode() method will return the appropriate object. I want to determine if a given Room
exists to avoid null reference excpetions upon trying to make a method call.