Jeff,
Why would you need this in the first place? Wouldn't a Hashtable be better
for matching menu items to their names?
Anyway, you cannot declare varibales the way you want it. You can however
access variables by their names by using Reflection, still the code would be
much more complicated than that you have imagined.
--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"Jeff Higgins" <Je*********@discussions.microsoft.com> wrote in message
news:3D**********************************@microsof t.com...
I would like to use a string variable to declare a variable.
How would I accomplish this goal?
string nameMainMenu = "mnuMain";
string nameMenuItem = "mnuFile";
MainMenu {nameMainMenu} = new MainMenu();
this.Menu = {nameMainMenu};
MenuItem {nameMenuItem} = new MenuItem("&File");
{nameMainMenu}.MenuItems.Add({nameMenuItem});