简体   繁体   English

C#错误:类型'x'已经定义了一个名为'y'的成员,它具有相同的参数类型

[英]C# error: Type 'x' already defines a member called 'y' with the same parameter types

On Visual C# Express , I get the following error with the code below: Visual C#Express上 ,我使用下面的代码得到以下错误:

'Type 'myComponent.SettingsComponent' already defines a member called 'SolveInstance' with the same parameter types' 'type'myComponent.SettingsComponent'已经使用相同的参数类型定义了一个名为'SolveInstance'的成员'

But I only used SolveInstance there. 但我只在那里使用SolveInstance What am I doing wrong and how would I be able to solve this on my own next time? 我做错了什么,下次我怎么能自己解决这个问题?

namespace myComponent
{
    public class SettingsComponent : GH_Component
    {
        protected override void SolveInstance(IGH_DataAccess DA)
        {
        }

        protected override void  RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
        {
        }

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (m_settings == null)
            {
                AddRuntimeMessage(warning, "You must declare some valid settings");
                return;
            }
            DA.SetData(0, m_settings);
        }
    }
}

It looks like you have two instances of 看起来你有两个实例

protected override void SolveInstance(IGH_DataAccess DA)

in your example class, one with an empty body and one with code. 在您的示例类中,一个具有空主体,另一个具有代码。

Try to find all occurences of SolveInstance in the project. 尝试在项目中找到所有出现的SolveInstance。 You will possibly find another definition of this method in a .designer.cs file. 您可能会在.designer.cs文件中找到此方法的另一个定义。 They are autogenerated and sometimes they cause duplicity problems. 它们是自动生成的,有时会导致重复性问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C#:专用模板方法-错误:类型“…”已经定义了具有相同参数类型的成员“…” - C#: specialized template method - Error: Type '…' already defines a member called '…' with the same parameter types 错误 CS0111:“程序”类型已经定义了一个名为“Main”的成员,具有相同的参数类型 c# - error CS0111: Type 'Program' already defines a member called 'Main with the same parameter types c# 已经定义了一个使用相同参数类型调用的成员 c# - already defines a member called with the same parameter types c# 类型'Startup'已经定义了一个名为'Configuration'的成员,它具有相同的参数类型 - Type 'Startup' already defines a member called 'Configuration' with the same parameter types 错误已使用相同的参数类型定义了一个名为“索引”的成员 - Error already defines a member called 'Index' with the same parameter types 错误 - 已经使用相同的参数类型定义了一个名为“InitializeComponent”的成员 - Error - already defines a member called 'InitializeComponent' with the same parameter types 错误1类型“ Pay”已经使用相同的参数类型定义了一个名为“ ComputePay”的成员 - Error 1 Type 'Pay' already defines a member called 'ComputePay' with the same parameter types 我该如何修复错误:Type Form1'已经定义了一个名为'Dispose'的成员,它具有相同的参数类型? - How can i fix the error: Type Form1' already defines a member called 'Dispose' with the same parameter types? 类型“Type”已经定义了一个名为“Equals”的成员,在 Equals(object) 上具有相同的参数类型 - Type 'Type' already defines a member called 'Equals' with the same parameter types on Equals(object) 错误2类型'WindowsForms2012Snowman.WindowsForms2012SnowmanForm1'已经定义了具有相同参数类型的名为'Dispose'的成员 - Error 2 Type 'WindowsForms2012Snowman.WindowsForms2012SnowmanForm1' already defines a member called 'Dispose' with the same parameter types
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM