Assuming we have a class InnerClass with attributes and getter/setter. We also have a class OuterClass containing the InnerClass.
e.g.
class InnerClass
{
If you mean accessing inner class members without exposing the inner class itself, you can use the following code. If you just want to expose this.innerClass, there is no difference to the way you expose the fields of InnerClass.
class OuterClass
{
private InnerClass innerClass
public int M_A
{
get
{
if (this.innerClass != null)
{
return this.innerClass.M_A;
}
else
{
throw new InvalidOperationException();
}
}
set
{
if (this.innerClass != null)
{
this.innerClass.M_A = value;
}
else
{
throw new InvalidOperationException();
}
}
}
}