0

Is it possible to convert a string value to a variable name ?

Considering the following example

AddNode(treeview, "root", "This is the root");

public void AddNode(TreeNode parent, string nodeName, string nodeValue)
        {
            // what i want to happen is here to be created node with the name "root"

            // TreeNode root = new TreeNode(nodeValue);
            // parent.Nodes.Add(root);

            // so is there a way to convert the string value of nodeName to 
            // somehow get it as a variable name

            
        }
4
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by __avd
0

If i understand your question correctly you can use the name property of the created treenode(root.Name = nodeName) to set the name of 'root; to a string.

0

>convert string to a variable name

Maybe you should have to look at Dictionary<K,V>.

Dictionary<string,string> val=new Dictionary<string,string>();
 val.Add("var1","value1");
 ...
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.