string one = "find";
combobox1.text = "one";
我想使用“一个”,即 ( combobox1.text
) 的字符串值作为现有变量string one
。这可能吗?
所有你仍然没有得到我的问题。我想使用combobox1.text的值,它是一个,一个是变量字符串,它的值是find。所以我想间接使用变量one的值。
对于这样的局部变量,您不能这样做。对于成员字段,您可以使用反射;对于当地人来说,最简单的方法是使用Dictionary
,例如,像这样:
IDictionary<string,string> vars = new Dictionary<string,string> {
{"one", "find"}
, {"two", "cancel"}
};
combobox1.text = vars["one"];
你必须使用:
combobox1.text = one;
希望能帮助到你