C# 错误:功能 'target-typed object creation' 在 C# 7.3 中不可用。请使用9.0或更高版本的语言

C# Errror: Feature 'target-typed object creation' is not available in C# 7.3. Please use language version 9.0 or greater

C#7.3这部分代码怎么写? new() 抛出语法错误。

Feature 'target-typed object creation' is not available in C# 7.3. Please use language version 9.0 or greater

private static List<ExcelModel> GetSetupData()
{
  List<ExcelModel> output = new()
  {
     new() { Id = 1, Type= "Normal", Mode= "Default" },
     new() { Id = 2, Type= "Normal", Mode= "Test" },
     new() { Id = 3, Type= "Typical", Mode= "Production" }
  };

  return output;
}

除非您使用的是 C# >=9.0(其中引入了 target-typed 对象创建),否则您需要在使用 new

时指定要创建的类型
 List<ExcelModel> output = new List<ExcelModel>(){
 new ExcelModel() { Id = 1, Type= "Normal", Mode= "Default" }
};