Saturday, April 12, 2008

[C++/CLI]for each restriction.

for each can be useful for iterating a container's item.
However that is ALL.
for each only used for iterating, NOT use change a value or add/remove element.

//array<>^>^ item_array2D
for each(array<MineItem>^ AR in item_array2D)
{

for each(MineItem MI in AR)
{
//It's ok that iterating and print out.
Console::WriteLine(MI.ItemIndexProperty);
//It's not make errors.
//However ItemIndexProperty value does not changed.
MI.ItemIndexProperty = ItemIndex::SIX;
}
}


By the way... google blogger post editor really suck...

No comments:

Powered By Blogger