T
tshad
I am trying to create a class that may have an error in the constructor.
For example:
using System;
public class Demo
{
public Demo ()
{
Some code that reads database and fails for some reason
}
}
If the constructor fails, is there a way to just return a null object?
Such that I could write:
Demo theDemo = new Demo()
if (theDemo == null) then ...
Thanks,
Tom
For example:
using System;
public class Demo
{
public Demo ()
{
Some code that reads database and fails for some reason
}
}
If the constructor fails, is there a way to just return a null object?
Such that I could write:
Demo theDemo = new Demo()
if (theDemo == null) then ...
Thanks,
Tom