相关疑难解决方法(0)

在字典中存储func时,参数类型不可分配

我有一个func,它接受一个T类参数并返回一个值.

我想将它存储在字典中,如下所示:

Dictionary<CustomerMilestones, Func<string, string>> coll = new Dictionary<CustomerMilestones, Func<string, string>>();

string Indicator = coll[CustomerMilestones.Ordered100Products].Invoke(customerId.ToString());

coll.Add(CustomerMilestones.Ordered100Products, Execute(Indicator);
Run Code Online (Sandbox Code Playgroud)

Execute是一个接受字符串但也返回字符串的方法.在最后一行,错误如下:

参数类型字符串不能分配给参数类型Func.

我究竟做错了什么?

c#

0
推荐指数
1
解决办法
1806
查看次数

标签 统计

c# ×1