public class abstract animal
{
// many fields
public string Name {get;set;}
public int id {get; set;}
// method, return self
public abstract animal getAnimalByID( int _id)
{
// databse connection
//get data from database and return an animal type
return animal; <-- cannot work, "return this" can work
}
}
public class dog : animal
{
public override dog getAnimalByID( int _id)
{
return (dog )base.getAnimalByID( _id);
}
}
I have a abstract base class and get data from database. dog has more fields and functions than animals and I want to return dog data type from database.
problem 1:
return (dog )base.getAnimalByID( _id); return access base class error
problem 2:
(dog) returns error too
first class’s method cannot be declared as abstract if i want to use base at second class.
The rest works fine after i took away the abstract.