S
Saravanan
Hi,
This may be a silly question. I would like to return null while creating a
new instance of a class and the validation inside the class constructor
fails.
For example:
class employee
{
public employee(int employeeid)
{
if(isemployeeexist(employeeid))
{
// validation success and proceed normally
}
else
{
// validation fails and needs to return null ?????
}
}
}
void main()
{
employee abc = new employee(1234);
if(abc == null)
{
....
}
}
How do i return null from a class constructor?
Any help will be much appreciated.
Thanks,
Saravanan.
This may be a silly question. I would like to return null while creating a
new instance of a class and the validation inside the class constructor
fails.
For example:
class employee
{
public employee(int employeeid)
{
if(isemployeeexist(employeeid))
{
// validation success and proceed normally
}
else
{
// validation fails and needs to return null ?????
}
}
}
void main()
{
employee abc = new employee(1234);
if(abc == null)
{
....
}
}
How do i return null from a class constructor?
Any help will be much appreciated.
Thanks,
Saravanan.