I'm communicating with an instrument asynchronously via tcp (TcpClient). There is a large but finite number of responses (which are converted to strings) that can be returned from the instrument and I would prefer not to have a large section of if-then-else statements. How does one go about making a SortedList where the value points to a member function?
I've tried the following
private SortedList<string, object> functionList = new SortedList<string, object>();
private void InitializeList()
{
functionList.Add("Time", ProcessTime(string)); // Invalid expression term 'string'
functionList.Add("Date", ProcessTime()); // There is no argument given that corresponds
// to the required formal parameter 'reply' of
// 'ProcessTime(string)'
}
private void ProcessTime(string reply)
{
// More complex processing here, but you should get the idea.
Console.WriteLine(reply);
}
I'm sure this has been asked before but I can't find where.