I know how to do this in C++:
class myClass : public baseClass1 private baseClass2 ...
How do I do likewise in C#?
This is what I have s开发者_运维技巧o far in C#
public class myClass : baseClass1, baseClass2
How do I specify that baseClass2 is private?
C# does not support multiple inheritance and it does not support private inheritance either.
C# does not have multiple inheritance. What you could do is a composite with baseClass2
.
When you have a class inheriting other classes you have no means of specifying access - shouldn't need to. The inherited members/properties/methods have the same access level as specified in the base class.
Use "has-a" (aggregation) instead of "is-a" (inheritance). Qualify calls to the desired class with the member name.
精彩评论