R
rn5a
What's wrong with the following code?
Dim arrColors(5) As ArrayList
arrColors(5) = New ArrayList
arrColors(0).Add("Red")
arrColors(1).Add("Blue")
arrColors(2).Add("Green")
arrColors(3).Add("Yellow")
arrColors(4).Add("Black")
Response.Write(arrColors(0).ToString & "<br>")
Response.Write(arrColors(1).ToString & "<br>")
Response.Write(arrColors(2).ToString & "<br>")
Response.Write(arrColors(3).ToString & "<br>")
Response.Write(arrColors(4).ToString & "<br>")
The above code generates the following error:
Object reference not set to an instance of an object.
pointing to
arrColors(0).Add("Red")
Thanks,
Ron
Dim arrColors(5) As ArrayList
arrColors(5) = New ArrayList
arrColors(0).Add("Red")
arrColors(1).Add("Blue")
arrColors(2).Add("Green")
arrColors(3).Add("Yellow")
arrColors(4).Add("Black")
Response.Write(arrColors(0).ToString & "<br>")
Response.Write(arrColors(1).ToString & "<br>")
Response.Write(arrColors(2).ToString & "<br>")
Response.Write(arrColors(3).ToString & "<br>")
Response.Write(arrColors(4).ToString & "<br>")
The above code generates the following error:
Object reference not set to an instance of an object.
pointing to
arrColors(0).Add("Red")
Thanks,
Ron