I have several fields, each one is like this:
field1
field2
field3
...
Using a loop with a counter, I want to be able to say fieldx. Where x is the value of the counter in that loop. This means if I have 6 entries in my array, fields1 – field6 will be given values.
Is fieldx possible?
You can do it with reflection, but in general it is better if you can declare your fields in an array. Instead of:
You can do this:
Then you can loop over the array setting the values: