I want something like this
public abstract class abc
{
public abstract void test();
}
public class def : abc
{
// ignore test(), this is concrete class which can be initialized
// test method is not needed for this class
}
public class ghi : def
{
public override void test()
{
// force test method implementation here
}
}
What are possible ways to do that. I want to ignore use of interface at GHI class as these are not under our application.
Edit
All of you are correct, but I need similar implementation. Point is I have various objects which has common functionality so I inherited from a class. I want to give this class to other ppl who must implement test method.
You can have the Test method in your base class as Virtual and leave the method body blank. Therefore you can override it wherever you want to. This is more of a hack and using an interface is a better way to go.
public abstract class abc
{
public virtual void test()
{
}
}
public class def : abc
{
// ignore test(), this is concrete class which can be initialized
// test method is not needed for this class
}
public class ghi : def
{
public override void test()
{
// force test method implementation here
}
}
Or
You can have another abstract class
public abstract class abc
{
}
public abstract class lmn : abc
{
public abstract void Test();
}
public class def : abc
{
// ignore test(), this is concrete class which can be initialized
// test method is not needed for this class
}
public class ghi : lmn
{
public override void test()
{
// force test method implementation here
}
} NOTE - This abstraction is completely dependent upon your domain. The suggestion is just a technical way to do it. Not sure if its aligned with the problem domain at hand.