how to created object referenced by a string
-
Does any one know how to do this? I want to set object y equal to object x. I only know the name of x because it's name is contained in someString. object x = new object(); string someString = "x"; // string set to object name //problem is here: object y = (the object whose name is contained in the variable someString i.e. "x") In case you are wondering why I need such a thing.... In my app someString is actually looked up in a table. It's a long story, as usual.
-
Does any one know how to do this? I want to set object y equal to object x. I only know the name of x because it's name is contained in someString. object x = new object(); string someString = "x"; // string set to object name //problem is here: object y = (the object whose name is contained in the variable someString i.e. "x") In case you are wondering why I need such a thing.... In my app someString is actually looked up in a table. It's a long story, as usual.
-
Does any one know how to do this? I want to set object y equal to object x. I only know the name of x because it's name is contained in someString. object x = new object(); string someString = "x"; // string set to object name //problem is here: object y = (the object whose name is contained in the variable someString i.e. "x") In case you are wondering why I need such a thing.... In my app someString is actually looked up in a table. It's a long story, as usual.
REflection is what you need, if you have the name of the variable as a string and need to get the variable.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
REflection is what you need, if you have the name of the variable as a string and need to get the variable.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Can you point me to a keyword or something I plug into google to get more specific info? Thanks