How to store function OR string as value in dictionary (C#) -


i need need create dictionary key string , values either (delegate function or string).

because, want implement call mechanism, wherein need function more processing returns string , need fixed string.

is there way in c#?

thank you

i think easiest way create dictionary<string, func<string>>. can hold call case. non-call case can create trivial lambda return hard coded value.

private dictionary<string, func<string>> m_map; public void addvalue(string key, string value) {   m_map[key] = () => value; } public void addvalue(string key, func<string> value) {   m_map[key] = value; } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -