R
R
Roman Koff2016-02-28 14:31:39
C++ / C#
Roman Koff, 2016-02-28 14:31:39

How to say in C# that a base class virtual method must be overridden?

How in the base class to say that its virtual method, when inherited, is required to be overridden?
To display an error during development if the method is not explicitly overridden in an inherited class.

public class _BaseClass
{
  public virtual void __Save() { throw new NotImplementedException(); }
}

As I understand it, this can be done, probably, using the appropriate filter. But what?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2016-02-28
@Zarinov

1) Make it abstract
2) Replace the base class with an interface

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question