Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

foreach question

Status
Not open for further replies.

WebStar

Programmer
May 1, 2002
69
DE
Hi, I have the next question:
in foreach (type identifier in expression) where expresion is a structure if I say identifier.a = value than the value is changed in expression structure too?
 
As far as I know you cannot make changes to objects that you get from the foreach command - they are read only.
To change the data, you would need to do a traditional for loop.
 
No not correct.

You cant make changes that affects how many objects there are. So you can't add or remove objects in a foreach-loop.

But you can change data for the object, not just read it.

Markus
 
Yeah I got the answer, thank you.
You are right Larsson. I've made a program and followed it step by step. You can change data into objects with foreach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top