0

In C#, I have a dictionary as below:

var myActionDictionary = new Dictionary<string, Action<string>();

myActionDictionary.add("Test1", Test1Method);

where it will run a method that takes string as a parameter and returns void when I invoke it.

private void Test1Method(string text)
{ return null;}

How do I change create a dictionary so that it runs a method and returns a string?

var myDelegateDictionary = new Dictionary<string, ???<string>();

myDelegateDictionary.add("Test2", Test2Method);

private string Test2Method(string text)
{ return text;}

What do I write for ??? and how do I declare a delegate? thanks

Johnathan Barclay
  • 18,599
  • 1
  • 22
  • 35
qed59
  • 51
  • 7

0 Answers0