Protected methods of a DLL

Asked

Viewed 89 times

-1

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 may or may not be called externally to DLL?

  • http://stackoverflow.com/questions/614818/what-is-the-difference-between-public-private-protected-and-nothing

1 answer

2


Yes, you must use the internal in each method that can only be called by the DLL.

The whole class can be internalalso. Actually this is the standard.

It can be used with protected also, since this constraint has to do with heritage and not with simple visibility.

Something like that:

public class Tricycle {
    //só pode ser acessado por tipos dentro da DLL
    internal void Pedal() { }
    //pode ser acessado por uma classe qualquer que derive desta, ou tipos desta DLL.
    protected internal int Wheels => { get; } => 3
}

I put in the Github for future reference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.