I have an array that gets accessed in very complex ways; is it possible to break in visual studio 2008 when a certain element of the array is accessed? Or the array itself is accessed?
Thanks.
I have an array that gets accessed in very complex ways; is it possible to break in visual studio 2008 when a certain element of the array is accessed? Or the array itself is accessed?
Thanks.
You can't set a breakpoint for when a certain element in the array is accessed, but you can set a breakpoint for when the array is accessed by changing it to a property, and putting the breakpoint in the get accessor.
So change this:
public string[] myArray;
To this:
private string[] myArray;
public string[] MyArray
{
get
{
return myArray; //put breakpoint here.
}
set
{
myArray = value;
}
}
You can use conditional breaks. Meaning that say you have a method where you pass as an argument the index of the array to be accessed, you can then use a condition to break when index is X.
To insert a conditional break right click on the break point an select condition.