Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Virtual function In Inherited Class

I have a class that inherits from LinkButton and I want to hide OnClinentClick from my class.

Somthing like this :

public class MyClass : LinkButton
{
    // some Code
}

And somewhere in code:

MyClass myclass = new MyClass();
MyClass.OnClinentClick = "";//this line must not be accessable

1 Answers

Hiding something from a class definition is not directly supported as it breaks OOP principles.

You could use the new operator, however, I wouldn't advise it. Personally, I would think about my design and/or use a NotSupportedException if there is no other way around it.

like image 51
Femaref Avatar answered Nov 26 '25 02:11

Femaref



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!