tags:

views:

79

answers:

2

if i have a protected method, can i pass in a parameter where the data type is declared internal?

+5  A: 

No, unless the type (with the protected member) is itself internal. Internal types cannot be part of a public/protected API, as the consumer would have no way of using it.

You could, however, consider using a public interface to abstract the type - i.e.

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

Generics can be useful for this too:

protected void Test<T>(T foo) where T : IFoo { }
Marc Gravell
+1  A: 

Not if the class that contains the protected method is externally visible. Thats because, some external class could derive from that class and would need to know the type of the parameter...

EricSchaefer