I am new to Stackoverflow and hope members forgive me if I ask the wrong question. I just started to learn C # and classes. A very important question that came to my mind is how to create an object model (hierarchy) of my classes. Let me explain:
Suppose I have a class called PEX . When I instantiate this class, it should contain some properties, methods, and another class called Windows . Now Windows will also contain some methods and properties and another class Window .
the Windows class and Window should not be accessible directly, but only through the PEX class.
Windows will return all instances of Windows ... basically, as in the Excel object model.
I could do foreach (Window window in PEX.Windows) {....} and other similar things ... I also read inheritance, but cannot get this object model.
public class PEX { public _Windows Windows; public PEX() { Windows = new _Windows(); } } public class _Windows { public _Window Window; private int _count; public _Windows() { Window = new _Window(); _count = 10; } public int Count { get { return _count; } } } public class _Window { private string _title; public _Window() { _title = "Roshan"; } public string Title { get { return _title; } } }
source share