R
Russ
If I do:
TextBox [] tb = new TextBox [10];
Does it actually create 10 textboxes? I would think so but that is
not what I want. I want to create an array of 10 pointers to
textboxes. So if:
TextBox [];
And then later:
TextBox box = new TextBox;
and then:
tb [0] = box;
What happens? Am I placing a pointer to box in the array, or am I
copying the box into the array and creating a new box in the process?
I think the latter, but again, that is not what I want. I want a
pointer or reference to the original box. I want at some point later
to be able to iterate through the array and get the value from each
TextBox that the array elements point to.
In C++:
TextBox *tb [10];
TextBox box = new TextBox;
tb [0] = &Box;
When I try something similar in C#, I get an error saying that
pointers can only be used in unsafe context. Somewhere I read that it
is possible to create an array of references. But then how can you
assign an item later, references are inviolate, right?
Can anyone tell me how to accomplish what I am trying to do.
Thanks, Russ
TextBox [] tb = new TextBox [10];
Does it actually create 10 textboxes? I would think so but that is
not what I want. I want to create an array of 10 pointers to
textboxes. So if:
TextBox [];
And then later:
TextBox box = new TextBox;
and then:
tb [0] = box;
What happens? Am I placing a pointer to box in the array, or am I
copying the box into the array and creating a new box in the process?
I think the latter, but again, that is not what I want. I want a
pointer or reference to the original box. I want at some point later
to be able to iterate through the array and get the value from each
TextBox that the array elements point to.
In C++:
TextBox *tb [10];
TextBox box = new TextBox;
tb [0] = &Box;
When I try something similar in C#, I get an error saying that
pointers can only be used in unsafe context. Somewhere I read that it
is possible to create an array of references. But then how can you
assign an item later, references are inviolate, right?
Can anyone tell me how to accomplish what I am trying to do.
Thanks, Russ