功能"目标类型对象创建"在 C# 7.3 中不可用。请使用语言版本 9.0 或更高版本



我在这一行中得到一个错误:

MessageParser<BestLimit> parser = new(() => new BestLimit());

我得到的错误是:

C#7.3中没有"目标类型对象创建"功能。请使用语言版本9.0或更高版本的

这个错误是什么?我如何修复它?

除非您使用C#>9.0(其中引入了目标类型对象创建(,您需要指定在使用new时创建的类型。

这是重新编写的代码:

MessageParser<BestLimit> parser = new MessageParser<BestLimit>(() => new BestLimit());

最新更新