F
fredd00
Hi
I would like to create a class that could give me a null item from the
contructor.
let me explain
let's say i want a foo object of id 123 from the database
public foo(int 123)
{
// look in database
item found, assign values to private variables, return object
// not found
return null
}
I know you can't return some thing from the constructor how can this
be done.
my second option was to use a manager
foo f = fooManager.GetFoo(123);
the manager builds a foo object and check for a non empty foo object
if the object is empty return null other wise return foo object.
it works but it does not prevent people from calling foo(123) and
getting an empty object.
what is the best way to go about this
thanks
I would like to create a class that could give me a null item from the
contructor.
let me explain
let's say i want a foo object of id 123 from the database
public foo(int 123)
{
// look in database
item found, assign values to private variables, return object
// not found
return null
}
I know you can't return some thing from the constructor how can this
be done.
my second option was to use a manager
foo f = fooManager.GetFoo(123);
the manager builds a foo object and check for a non empty foo object
if the object is empty return null other wise return foo object.
it works but it does not prevent people from calling foo(123) and
getting an empty object.
what is the best way to go about this
thanks