.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

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

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -