array<System::Byte> ^temp_2 = gcnew array<System::Byte>(256); System::Int32 count_1 = 0; for each(System::Byte %element in temp_2) { element = System::Byte::Parse(count_1.ToString()); count_1 +=1; }; for each(System::Byte element in temp_2) { System::Console::WriteLine(element.ToString()); };
System::Console::ReadLine();
(fig. 1)
I don't understand why the identifier has to be a tracking reference to modify the item in the array. As I learnt just `element`, not `%element`, is a pointer to what's the array pointing to. When I try to deference the pointer like below. (fig. 2)
for each(System::Byte element in temp_2)
{
element = System::Byte::Parse("23");
};
the elements don't get modified. but when I do: (fig. 3)
the elements do get modified. In fig 2. I have deferenced the pointer but the element in the array doesn't get modified. I don't understand why. Can someone please explain this to me.for each (System::Byte %element in temp_2)
{
element = System::Byte::Parse("23");
};