Can I use FOR EACH on an array of structures?
-
Hi, I'm using Visual Studio 2005 C++/CLI. I would like to access an array of structures using the for each construct. Is this possible? Buck
ref struct TestStruct
{
int i;
};array<teststruct^> ^teststructarray = gcnew array<teststruct^>(20);
for (int i = 0; i < 20; i++)
teststructarray[i] = gcnew TestStruct();for each (TestStruct ^teststruct in teststructarray)
{
teststruct->i = 42;
}value struct TestValStruct
{
int i;
};array<testvalstruct> ^testvalstructarray = gcnew array<testvalstruct>(20);
for each (TestValStruct %testvalstruct in testvalstructarray)
{
testvalstruct.i = 42;
}That's better :)
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Tuesday, July 1, 2008 8:08 PM
-
Hi, I'm using Visual Studio 2005 C++/CLI. I would like to access an array of structures using the for each construct. Is this possible? Buck
BuckBrown wrote:
Is this possible?
Yes. Try it! :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
Hi, I'm using Visual Studio 2005 C++/CLI. I would like to access an array of structures using the for each construct. Is this possible? Buck