Forced compiler to crash the build process when hiding a method or property without a “new” keyword

Are there any settings in visual studio that allow the compiler to generate an error when a method or property hides a method or property from the base class without using the “new” keyword?

the compiler is currently generating a warning

class A
{
  void F(){ ... }
}

class B : A
{
  void F(){ ... } //force build error because no "new" keyword is used
}

thank

+3
source share
1 answer

Go to your project properties and set the radio alert “warning as errors” to “all” or enter the warning code that you want in the highlighted text box.

+4
source

Source: https://habr.com/ru/post/1791454/


All Articles