Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you "override" an Internal Class in C#?

There's something I want to customize in the System.Web.Script.Services.ScriptHandlerFactory and other .NET stuff inside an internal class. Unfortunately, it's an internal class. What options do I have when trying to customize a method in this class?

like image 858
danmine Avatar asked Oct 13 '08 02:10

danmine


People also ask

Can you override a class C#?

In C#, a method in a derived class can have the same name as a method in the base class. You can specify how the methods interact by using the new and override keywords. The override modifier extends the base class virtual method, and the new modifier hides an accessible base class method.

Can we override private method in C#?

private methods of a class are not visible in its child class so they won't get inherited. Save this answer. Show activity on this post. No, you can't override private elements, they're effectively final (because they're never visible from a subclass to be overriden.)

Can internal class have public methods?

The short answer is that it doesn't matter. Public methods of an internal class are internal. To the compiler, the internal/public method distinction only matters for public classes.


1 Answers

You might find this recent article enlightening. Basically, it says that you can't override anything marked internal, and the source is about as authoritative as it gets. Best you can hope for is an extension method.

like image 187
Joel Coehoorn Avatar answered Nov 10 '22 11:11

Joel Coehoorn