简体   繁体   English

C#抱怨没有实现接口方法

[英]C# Complains that an Interface Method is not Implemented

namespace RepositoryFactory.Interface
{
    public interface ISelectionFactory<TIdentityObject> 
    {

        DbCommand ConstructSelectCommand(Database db, TIdentityObject idObject);
    }
}


namespace SafetypadDAL
{
    public class T_INCIDENT_SelectFactory:ISelectionFactory<T_INCIDENT>
    {
        public DbCommand ConstructSelectCommand(Database db, T_INCIDENT idObject)
        {
            //my business codes will be here

            return command;
        }
    }
}

This is that program. 这是那个程序。

Here you can not find any wrong signature. 在这里您找不到任何错误的签名。

You may have implemented a method called ConstructSelectCommand but with the wrong signature, so it wouldn't match the method. 您可能已经实现了一个名为ConstructSelectCommand的方法,但签名错误,因此与该方法不匹配。

If you're using VS2005 or later, click in the interface name in your class declaration, and press Ctrl and period (dot). 如果您使用的是VS2005或更高版本,请在类声明中单击接口名称,然后按Ctrl和句点(点)。 It will offer to generate the method stubs for you. 它会为您生成方法存根。

If you really, really think you've done the right thing, please post your declaration of that method. 如果您确实真的认为自己做对了,请发布该方法的声明。 Are you sure you've made it public, for instance? 例如,您确定已公开吗? (Or implemented the interface explicitly, of course.) (当然,也可以显式实现该接口。)

EDIT: Is it possible that Database in the two signatures refer to different types? 编辑:这两个签名中的Database是否可能引用不同的类型? What happens if you try what I suggested in terms of getting Visual Studio to generate the stub? 如果尝试使用我建议的使Visual Studio生成存根的方法,会发生什么?

You haven't implemented it. 您尚未实现。 Post the relevant part of the code, if you like. 如果愿意,请发布代码的相关部分。 Probably you can event instruct your IDE to attempt the implementation for you, just to get the exact signature. 可能您可以通过事件指示IDE尝试为您实施实现,只是获得确切的签名。

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

相关问题 如何调用在接口中定义并在C#中的类中实现的方法? - How to call a method defined in interface and implemented in class in C#? C#调用抽象接口实现中的未实现方法 - C# calling un-implemented method in abstract interface implementation 通过由基类c#实现的接口调用类的方法 - Calling a method of a class through the interface implemented by the base class c# 如何将int参数传递给C#中的DATASET实现的接口方法 - How to pass int parameter to DATASET implemented interface method in C# 仅当在 C# 中实现时才在接口实现上调用泛型方法 - Call generic method on interface implementation only if implemented in C# 为什么在类中实现的C#接口方法必须是公共的? - Why must an C# interface method implemented in a class be public? 如何从 C# 中的接口隐藏已实现属性的设置方法? - How to hide set method of an implemented property from an interface in C#? C#:为什么调用实现的接口方法对于类变量比对接口变量更快? - C#: Why calling implemented interface method is faster for class variable than for interface variable? 在C#中使用依赖注入时,为什么调用接口方法会自动调用实现类的方法? - When using dependency injection in C#, why does calling an interface method automatically call the implemented class' method? 这个COM接口可以用C#实现吗? - Can this COM interface be implemented in C#?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM