Reputation: 9526
I have the class ImplementationDetail
which I would like to keep internal, e.g.:
internal class ImplementationDetail
{
}
I have GenericBaseClass
that uses its parameter privately, e.g.:
public class GenericBaseClass<T>
{
private T useImplementationDetail;
}
And, I have a Derived
class that specifies to use ImplementationDetail
, e.g.:
public class DerivedClass: GenericBaseClass<ImplementationDetail>
{
}
This results in the error CS0060 Inconsistent accessibility; which is caused by ImplementationDetail
being internal
whereas DerivedClass
is public
.
How can I avoid the CS0060 compiler error while keeping ImplementationDetail
internal
?
Upvotes: 2
Views: 142
Reputation: 9526
It is not possible.
You have to use a public interface or class. See the comments of @DavidG, @Jonesopolis.
Upvotes: 0
Reputation: 4668
Instead of using an internal class, use an interface. Then use explicit implementation on the methods you want to keep private. That way, they're never exposed.
Upvotes: 1