将字符串调用为Function [英] call string as Function
问题描述
我想要州和城市的硬编码..
i我有50个函数,因为我有50个状态,我从中调用了一个关于combobox1_selectedindexchanged的函数事件。
。
因为我创造了一个包含50个案例的开关案例。其中combobox1的选定索引作为案例编号传递。
现在要添加10个函数,我认为开关案例不方便,
。
所以我有一个想法,是否可能?
i want to hard code for states and cities..
i am having 50 functions as i am having 50 states, from which i am calling a function on combobox1_selectedindexchanged event.
.
for that i have create a switch case with 50 cases. where combobox1's selected index is passed as a case no.
now 10 functions are to be added, i think switch case is not being convenient for that,
.
so i have a idea, is it possible?
functionName+combobox.selectedindex+();
这样我的60个案例将减少到只有一个功能?
。
或者还有其他选择..
。
so that my 60 cases will reduced to only one function ??
.
or there is any other option..
.
推荐答案
你可以使用一组代表,例如,见:功能指针数组? [ ^ ]。
You might use an array of delegates, see for instance, here: "Array of Function Pointers?"[^].
这篇关于将字符串调用为Function的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!