There is such code:

class A { protected virtual int Variable { get; private set; } } class B : A { public override int Variable { get; private set; } } 

Why the error occurs: "Error CS0507 'B.Variable": it is impossible to change access modifiers when overriding "protected" inherited from "A.Variable". "???

  • What are you trying to do by changing protected to public? In fact, these are already different properties, because the first is a class property and only that, and the second is generally accessible. - Monk
  • @Monk But I need it to be public! - PECHAIRMINE
  • To make it public in B? Can't make it public in A? - Monk
  • if you want to make it public, use the overlap in which the base field is set and returned. - Grundy

0