Click here to Skip to main content
15,891,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I want to design a solution, but facing a problem because of limited knowledge of OOPs concept. My requirement is as follows

Assume I have 4 classes
Class A
Class B
Class C
Class D

I want object of class D can only be allowed to create, or class can only be accessible in Class C. Same Class C object and class itself can be allowed access and created in Class B. Class D should not have access to class B.
Same Class A should not have access to C, D. It only have access to B, and it can create object of B.

How we can implement with best possible architecture in C#.

With Best Regards.
Posted
Comments
BillWoodruff 23-Nov-13 21:44pm    
You could implement some form of "class hiding" ... adding a level of indirection to access them ... by nesting Classes, but I do not think you can implement what you describe here in C# .NET.

I can't imagine a case of program design that would require the type of Class relationships you describe here.

C# and .NET does not allow access constraints of this kind. The access rules are much simpler and are well described in MSDN:
http://msdn.microsoft.com/en-us/library/ms173121.aspx[^],
http://msdn.microsoft.com/en-us/library/vstudio/wxh6fsc7.aspx[^].

—SA
 
Share this answer
 
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 23-Nov-13 20:35pm    
Being useful, these links are totally irrelevant to the question.
—SA
or by using different namespaces you can deal with your problem
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900