المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Debugging a getter



C# Programming
10-11-2009, 09:21 AM
Hi,

I am using the following code for testing purposes:
public class VariousTests
{
public static void Main(string[] args)
{
AClass c = new AClass();
int y = c.DemandSupplyMatrix[0, 0]; // breakpoint 2
}
}

class AClass
{
private int[,] _aMatrix = null;
public int[,] DemandSupplyMatrix
{
get
{
if (_aMatrix == null)
_aMatrix = new int[9, 4];

return _aMatrix; // breakpoint 1
}
}
}

I run it until I hit breakpoint 2 and I expect to see DemandSupplyMatrix being null in the debugger. Instead, it appears to have been already instantiated, and I have never hit breakpoint 1...

I really need to debug the getter but it seems that I have no chance.
Is this normal or am I missing something?

Bogdan.