Can anyone explain this to me? This sample from the wikipedia page
makes sense (in that without the '%' tracking ref the strings in arr
remain uninitialized because the for each loop passes items by value)
http://en.wikipedia.org/wiki/C%2B%2B/CLI
array<String^>^ arr = gcnew array<String^>(10);
int i = 0;
for each(String^% s in arr)
{
s = gcnew String(i++.ToString());
}
So far, so good. But then why does this loop below (without the
tracking ref) set the cell values in the table as if they're passed by
ref? The % isn't needed here, why not?
In fact if the tracking ref is supplied (DatagridViewCell^%), then the
program throws an access violation error when the cells value is
assigned.
for each( DataGridViewCell^ driverCell in driverRow->Cells )
{
driverCell->Value = "BUT";
}
Many thanks,
Duncan