.net - Storing a list of methods in C# -


i have list of method call in specific order. therefore want store them either in ordered list or in table specified index. way list thing change day want change call order.

i found this article explaining how using array , delegates. read in comments , other places done using dictionary , or linq. advices ?

you can define action objects, parameterless delegates return void. each action pointer method.

// declare list list<action> actions = new list<action>();  // add 2 delegates list point 'somemethod' , 'somemethod2' actions.add( ()=> someclass.somemethod(param1) ); actions.add( ()=> otherclass.somemethod2() );  // later on, can walk through these pointers foreach(var action in actions)     // , execute method     action.invoke(); 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -