private void _LoadClients() { _colClients.Clear(); MessageBox.Show(_colClients.Count.ToString()); // I addd this csClients oClients = new csClients(); oClients.LoadData(this.iRecordId); _colClients = oClients.colData; }I instantiated the class with a breakpoint on this line:
csCompany oCompany = new csCompany();
If I press F10 to step over, the MessageBox never fires, so I assume the method is not being called. But when I hover the mouse over oCompany and expand it, the MessageBox fires, so I'm concluding that the property GET is being run during debug, which is calling _LoadData.class csCompany { public int iCount = 0; private ArrayList _colClients = new ArrayList(); public ArrayList colClients { get { if (_colClients.Count == 0) { _LoadClients(); } return _colClients; } } private void _LoadClients() { iCount = 100; } }Then, I ran this:
namespace Test { class Program { static void Main(string[] args) { csCompany oCompany = new csCompany(); int x = oCompany.iCount; // Returns 0; } } }If I step over the instantiation, x is 0. I, But, if after the instantiation I hover the mouse over the variable, x is then 100.