Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

internal methods and data structures .

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

like image 209
leora Avatar asked Aug 28 '26 12:08

leora


1 Answers

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 { }
like image 94
Marc Gravell Avatar answered Aug 30 '26 03:08

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!