If objects contains null or empty then how to validate or check the condition for the same?
How to bool check whether object obj is null
or
The problem that you are running into is that your object is of type, well, object. In order to evaluate it with string.IsNullOrEmpty, you should pass your object in with the cast to (string)
like so:
static void Main(string[] args)
{
object obj = null;
double d = Convert.ToDouble(string.IsNullOrEmpty((string)obj) ? 0.0 : obj);
Console.WriteLine(d.ToString());
}
This will work fine since you are not explicitly calling .ToString on your (nonexistent) object.