|
-
Aug 6th, 2007, 04:08 AM
#5
Re: How do you cycle through an array of objects?
OK, I just did some testing of my own and it seems that you can set fields/properties of reference types, i.e. classes, in a foreach loop like that but you can't do so with value types, i.e. structures. Thus I assume that your Room type is a structure.
This is explained by the fact that in your code q will be a copy of the actual value in the array, so setting its fields/properties is pointless because it will not affect the original. If you want to change fields/properties of an array of structures then use a for loop instead of a foreach loop:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|