I have a multiple textboxes in a form, and with the typed information I create an object called UserClass
. I want to create multiple users and for this I have different textboxes
called tbName1
, tbName2
etc. Is it possible to use a variable in the textboxname
? E.G. tbName[variable].Text
newUsers.Add(new ClassLibrary.UserClass
(
"AAAAAAAA",
tbName[variable].Text, //Is it possible to do something like this?
" ",
tbLastname[variable].Text,
tbEmail[variable].Text,
" ",
"0497111111",
"0611111111",
"USER"
));
I'm afraid you won't be able to declare a variable on runtime as all variables have to be declared before compilation.