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
2008-12-21 13:31:22
+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
2008-12-21 13:33:14