I know it sounds a bit weird, but I will try to explain it: suppose I have a class with a lot of properties, and all of them are read-only, so this class is the only one which can modify its properties (it is listening to an event, and fills the properties with the information contained on that event).
But, I want to encapsulate some of the properties on some structs, to create a well organized hierarchy, so these structs'properties should be read-only too, except for the owner class. For example:
public class A
{
private int a1;
public int A1
{
get{ return a1; }
}
private B structB;
public B StructB
{
get{ return structB; }
}
private method eventListenerMethod(...)
{
a1 = someValue;
structB.B1 = otherValue; //I want that only this class can modify this property!
}
}
public struct B
{
private int b1;
public int B1
{
get{ return b1; } // This property should be modifiable for Class A!!
}
}
I think I cannot do that, but does anyone know how can I achieve it? Thank you very much in advance.