I have a class which gets a object from the external system. I want to validate my parameters are correct. It seems my object is not null even though I sent a wrong value to the service.Basically I want to check mySalesOrderHeader
contains a valid order number or not.
For example, if (mySalesOrderHeader != null) { Do My Stuff}
I am checking this condition once mySalesOrderHeader
is retrieved from the system. Inside my if condition[Where {Do My Stuff}]
is located, I am accessing its property and checking its existence.
if(string.IsNullOrEmpty(mySalesOrderHeader.OrderNumber)){}
But in here it throws a null reference exception. How can I check a property is null, if my parent object does not have the value in it.
Note: I am using C# 3.0