Dictionary with Delegates of different types: Cleaner, non string method names?

后端 未结 1 1354
失恋的感觉
失恋的感觉 2021-01-13 13:49

There has to be a cleaner method. Currently I have:

... Constructor()
{
      parseDictionary = new Dictionary()
            {
         


        
1条回答
  •  迷失自我
    2021-01-13 14:11

    Just cast to the right kind of delegate:

    parseDictionary = new Dictionary()
    {
        { typeOfStream.SOME_ENUM_VAL, (ParseDelegate) MyMethod) },
        { typeOfStream.SOME_OTHER_ENUM_VAL, (ParseDelegate) MyOtherMethod }
    };
    

    0 讨论(0)
提交回复
热议问题