Fabiano
Fabiano

Reputation: 5194

force compiler to fail build process when hiding method or property without "new" keyword

Are there any settings in visual studio that enable 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?

currently the compiler generates a warning

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

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

Thanks

Upvotes: 3

Views: 219

Answers (1)

Johann Blais
Johann Blais

Reputation: 9469

Go into your project properties and set the radiobutton "treat warning as errors" to "all" or type the warning code you want in the dedicated textbox.

Upvotes: 4

Related Questions