Internal methods and data structures.

If I have a protected method, can I pass a parameter where the data type is declared internal?

+3
source share
2 answers

Not if the type (with the protected element) is internal in itself. Internal types cannot be part of a public / secure API, as the consumer will not be able to use it.

However, you can use the open interface for the abstract type - i.e.

public interface IFoo {}
internal class Foo : IFoo {}
public class Bar {
    protected void Test(IFoo foo) {}
}

The following generalizations may also be useful for this:

protected void Test<T>(T foo) where T : IFoo { }
+6
source

Not if the class containing the protected method is externally visible. This is because some external class can be obtained from this class and must know the type of parameter.

+1
source

All Articles