【问题标题】:The same identifier is considered by the C# compiler as a different type in the same function [closed]C#编译器将相同的标识符视为同一函数中的不同类型[关闭]
【发布时间】:2017-09-25 13:26:18
【问题描述】:

我有一个扩展方法,它接受三个相同类型名称的参数。

问题在于 C# 编译器将第一个和第二个参数解析为类型 ServerModels.Action,但第三个参数解析为 System.Action。

完全相同的标识符怎么可能被认为是不同的类型?

Microsoft Visual Studio 专业版 2013
版本 12.0.40629.00 更新 5
微软 .NET 框架 4.5

【问题讨论】:

  • 动作 动作
  • 他们同名。动作s vs 动作
  • 我看到的是 ServerModels.Action 和一个 System.Action,因为您的代码看起来像 Actions action1, Actions action2 Action action3 动作三正在作为不同的对象类型传递。我怀疑您只需要将 action3 类型更改为 Actions 而不是 Action

标签: c# visual-studio compiler-errors


【解决方案1】:

第三个解析为System.Action,其他参数为ServerModels.Actions(注意“s”)

【讨论】:

    【解决方案2】:

    我看到ServerModels.Action 和一个System.Action,因为您的代码看起来像Actions action1, Actions action2 Action action3 动作三正在作为不同的对象类型传递。我怀疑您只需要将 action3 类型更改为 Actions 而不是 Action

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-18
      • 1970-01-01
      • 2014-11-21
      • 2021-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多