I have arrayList of objects and want to assign a value to an attribute(string) of object which is in arrayList
I tried
for (int i=0; i < arrayListofObj.Count; i++)
{
arrayListofObj[ i].string= maskedTextBox8.Text;
}
But it doesn't work.
thank you

accessing attribute of the object in the objects' arrayList
Pete Orologas
For future reference 'it doesn't work' is not very helpful. Instead, try posting the error message you get from the compiler.
In this case, the error message will be that object does not contain a string property. This is true. Why are you storing an array of objects If they are all of the same type, then create an array of that type. If not, if you wrote the objects in the array, then you should put the string property in an interface, so you can cast the object to an instance of the interface and set this property. You could also use foreach to iterate through the array, and make the interface the object type you use in you foreach statement.
Gary McAllister
Hi,
I am thinking your problem is fixed. So, i am marking this post as Answered. If you are still facing same problem then you can reopen the question by clicking on "Unmark as Answer" button on my reply.
Thank you,
Bhanu.
Hawkins Dale
Kari,
Does Christian's reply solve your problem If no, then please give us details of the exception that you are getting so that we can help you out!!
Thanks.