Warning: new protected member declared in sealed class

Warning: new protected member declared in sealed class

If you are getting the above warning from your C# class, it’s because you are trying to declare a protected member in a Sealed class, it’s a sort of logically contradicting, because the fundamental principle about a Sealed Class is that it cannot be inherited and the definition of a Protected member is that the member can be used within a class and also within the derived class. So if you have a base class with a Protected member, and you derive a class from the base class, then the Protected member in the base class is available in the derived class.  So declaring a Protected member in a Sealed class is a bit contradicting.

But it is still a warning and not an error, so you can ignore it, but if you are bothered by the warning, you can just disable the warning by using the pragma disable code.

#pragma warning disable 0628

            // Your code

#pragma warning restore 0628