Monday, 15 August 2011

.net - Accessing nested classes from an instance created by the parent in C# -



.net - Accessing nested classes from an instance created by the parent in C# -

i'm having problem class hierarchy in c#. have looked around , tried few things can't find reason why isn't working, perhaps don't understand visibility of nested classes.

class settings { class graphics { class resolution { public int width { get; set; } public int height { get; set; } } public resolution resolution = new resolution(); public bool vsync { get; set; } } public graphics graphics = new graphics(); public settings() { // graphics.resolution not visible here, nor graphics.vsync; } }

i want graphics , resolution nested because don't want them accessible anywhere other through settings.

the default accessibility of inner class private.

change public or internal gain access outside encompassing class.

an unrelated issue in code declaring members same name - resolution , graphics both class names , other members (property , field, respectively).

c# .net class nested visibility

No comments:

Post a Comment