I have a DLL that has several internal methods, I want to protect these internal methods so that they are called only by the DLL itself.
Is there any way to define which methods can be called externally from the DLL?
I have a DLL that has several internal methods, I want to protect these internal methods so that they are called only by the DLL itself.
Is there any way to define which methods can be called externally from the DLL?
Yes, you should use internal
for each method that can only be called by DLL.
The whole class can be internal
as well. In fact this is the default.
It can be used with protected
also, since this restrictor has to do with inheritance and not with simple visibility.
Something like this:
public class Tricycle {
//só pode ser acessado por tipos dentro da DLL
internal void Pedal() { }
private int wheels = 3;
//pode ser acessado por uma classe qualquer que derive desta, ou tipos desta DLL.
protected internal int Wheels {
get { return wheels; }
}
}