Reputation: 159
Assume I have a class as:
public abstract class BaseClass
{
internal abstract void Add(int i , int j);
}
a child class as:
public class Child : BaseClass
{
}
as I am inheriting Child class from BaseClass I should implement Add()
method in it
but I do not want to implement Add method here is it possible? If possible how can I achieve it?
Thanks in advance
Upvotes: 4
Views: 1489
Reputation: 9780
If you dont want to implement the method, you could do the following:
Mark Child
as abstract too:
public abstract class Child : BaseClass { }
Or, make the method virtual:
public abstract class BaseClass
{
internal virtual void Add(int i , int j) { }
}
Or, override the method and make it virtual:
public abstract class Child : BaseClass
{
// Empty method does nothing; also could be overridden.
internal override void Add(int i , int j) { }
}
Upvotes: 5
Reputation: 431
You will have to declare your Child class as abstract too, if you don't want to implement Add function in Child class.
Upvotes: 4