c# - How to call functions from data structure? -
i able describe actions function calls represented in datastructure. able loop through data structure , call functions.
this pseudo-code describes achieve:
static void main(string[] args) { action[] actions = new action[] { new action(doaction1(5)), new action(doaction1(7)), new action(doaction2("100201")), }; foreach (action action in actions) { action.<run action function>; } } public static void doaction1(int x) { } public static void doaction2(string x) { }
it kind of looks delegates, not quite.
any ideas on how achieve this?
this you're looking for?
action[] actions = new action[] { new action(()=>doaction1(5)), new action(()=>doaction1(7)), new action(()=>doaction2("100201")) }; foreach (action action in actions) { action(); }
Comments
Post a Comment