There is a set of methods like:
Foo(int, float, params objects[])
Goo(int, params objects[])
Too()
each taking different number of & type of parameters (so are return values).
I read an integer (an index) from a database. The integer corresponds to one of the above method (1 for Foo, 2 for Goo and 3 for Too).
How do I store above methods (as delegates) in a collection so that I can call appropriate method by indexing into the collection using the integer read from db as index.
You could just use a Delegate[] - when you read the integer, you'll then need to cast the relevant array value to an Action<int, float, object[]>, an Action<int, object[]> or an Action before you call it though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With