![]() |
| ||
| Null reference in array When I want an array of integers with 4 rows and 2 columns I do int[,] array = new int[4, 2]; and then use array[0, 0]=123; to set the first element. So for the matrix input usercontrol I'm working on I thought I need something like : TextBox[,] elements = new TextBox[5,5];(This compiles) but when I try to access an element of this array ( e.g. elements[0,0].Name="foo";) I get a Null ref exeption. When I do elements[r, c] = new TextBox(); elements[r, c].Name = "foo";All is well. I'm confused here! Why two times new TextBox? |
| ||
| Re: Null reference in array int value type.. TextBox reference type you should new it... |
| ||
| Re: Null reference in array Phew! More than 10000 views in one day. Seems to me a lot of people have the same problem I had. |
| ||
| Re: Null reference in array I am proud I could solve it to my expert :) |
| All times are GMT -4. The time now is 7:05 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC