Hi,
I have an object, and inside are different variables that I populate during runtime, one of the is an array of string
So I populate it like this
Then I have a List of these objects like this and add my objects to it, perform stuff on the list like sorting and search etc.
At the end I wanted to iterate through the list and for a certain object I want to access the array and print out the contents. I tried the following and it does not work and I don't understand why.
I get an error in the debugger that says I have to instantiate a new object using the new keyword. I don't get it, the object already exists and I can see values in the array when I watch the variable. How do I access the array values? Thanks in advance for any help
I have an object, and inside are different variables that I populate during runtime, one of the is an array of string
Code:
[B]string [] array = null;[/B]
Code:
[B]object.array[0] = "something";[/B]
Code:
[B]List<object> objectList = new List<object>; objectList.Add(object1); objectList.Add(object2); ...[/B]
Code:
[B]foreach(object o in objectList){
foreach(string s in o.array){
Console.Writeline(s);
}
}[/B]
Comment