Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic variable name in C#

Status
Not open for further replies.

marcasii

Programmer
Aug 27, 2001
109
AU
Hi I have a fucntion that takes the name of a DropDownList as a string parameter but I need to use the string to reference a DropDownList ie:

Code:
void populateDropDownList (string dropDownListName) {
 dropDownListName.Items.Add(new ListItem("some","thing"));
}
 
Forget it. Worked it out. Just needed to be:

Code:
void populateDropDownList (DropDownList dropDownListName) {
 dropDownListName.Items.Add(new ListItem("some","thing"));
}

-----------------------------------

I feel I am talking to myself?
 
Yup. Whenever you see "string" think to yourself "object of type string". After that, it's an easy step to start thinking things like "object of type ListBox" or "object of type Form".

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
I wish more people talked to themselves. It is very nice to see a post answered by the same person who started it. Too many times we see 'I got it never mind' or someone else posts the answer and the query poster does not reply back.
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top