T
Tony Johansson
Hello!!
Assume you have an Interface called ITest with these three method
declarations.
interface ITest
{
void foo1();
void foo2();
void foo3();
}
Assume that you "inherit" this interface to an abstract class called ABCBase
like this.
abstract public class ABCBase : ITest
{
//Here you add some more.
abstract public void goo1();
abstract public void goo2();
abstract public void goo3();
abstract public void foo1();
abstract public void foo2();
abstract public void foo3();
}
Below we have class RealClass that implements all six methods that must be
implemented.
Now to my question I have noticed that I must redeclare all three from the
interface like this
abstract public void foo1(); abstract public void foo2(); abstract public
void foo3();
in the abstract ABCBase class despite having a definition in the RealClass.
Does it really have to be in that way. In a way it feels unnessessary to do
this. Is this a misstake in
the construction of C# having to declare methods in the abstract class when
the same method exist in the interface.
My next question is it common to have this construction with an interface
then an abstract class
that "inherit" and finally the the real class that make the method
definitions.
public class RealClass : ABCBase
{
void foo1()
{//some code here }
void foo2()
{//Some code here}
void foo3()
{//some code here}
void goo1()
{//some code here }
void goo2()
{//Some code here}
void goo3()
{//some code here}
}
//Tony
Assume you have an Interface called ITest with these three method
declarations.
interface ITest
{
void foo1();
void foo2();
void foo3();
}
Assume that you "inherit" this interface to an abstract class called ABCBase
like this.
abstract public class ABCBase : ITest
{
//Here you add some more.
abstract public void goo1();
abstract public void goo2();
abstract public void goo3();
abstract public void foo1();
abstract public void foo2();
abstract public void foo3();
}
Below we have class RealClass that implements all six methods that must be
implemented.
Now to my question I have noticed that I must redeclare all three from the
interface like this
abstract public void foo1(); abstract public void foo2(); abstract public
void foo3();
in the abstract ABCBase class despite having a definition in the RealClass.
Does it really have to be in that way. In a way it feels unnessessary to do
this. Is this a misstake in
the construction of C# having to declare methods in the abstract class when
the same method exist in the interface.
My next question is it common to have this construction with an interface
then an abstract class
that "inherit" and finally the the real class that make the method
definitions.
public class RealClass : ABCBase
{
void foo1()
{//some code here }
void foo2()
{//Some code here}
void foo3()
{//some code here}
void goo1()
{//some code here }
void goo2()
{//Some code here}
void goo3()
{//some code here}
}
//Tony