I have an issue with accessibility of class members.
I have 3 classes that work together and need full access to each others properties. classA, classB, classC
However classA is uses somewhere else and all users of that class should only have read access to all structures!!
The classes look like this:
public class classA
{
public ClassB B { get ; }
...
}
public class classB
{
ClassC C { get ; set ; }
...
}
public class classC
{
ArrayList L { get ; set ; }
...
}
How can I manage that classA and classB have full access on classC, but all users of class A cannot modify anything inside?
For example this is still possible :(
classA A = new A();
A.B.C.L.Add( something);
even if A.B cannot be modified due to the missing set.
One possibility I see is, that property A.B returns a deep-copy of the structure, so that modifying A.B does not affect the source structure, but I'm not really satisfied with that.
Is there a way that write access is checked at compile time as if I used 'readonly' or omit a 'set;'?