实施接口时出错 [英] Error in implementing an interface

查看:92
本文介绍了实施接口时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public interface ICaseStageTransitionControlView : IControlView
{
Button PassButtonToControl { get;set;}
}

namespace Prateep.MSC.Web.Mod.CSE
{
public partial class CaseStageTransitionControl : ICaseStageTransitionControlView
{
 public Button PassButtonToControl
        {
            get { return _button; }
            set { _button = value; }
        }
}





Error	4 'Prateep.MSC.Web.Mod.CSE.CaseStageTransitionControl' does not implement interface member 'Prateep.MSC.Web.Mod.CSE.Views.ICaseStageTransitionControlView.PassButtonToControl 'Prateep.MSC.Web.Mod.CSE.Case.CaseStageTransitionControl.PassButtonToControl' is either static, not public, or has the wrong return type.



我检查了3次,但不知道有什么问题,抱怨有任何帮助.



I checked 3 times i have no clue whats its complaining any help would be appreciated .

推荐答案

我看到的错误是您未在_button中定义变量您的班级声明.

尝试以下操作:
The error I see is that you don''t define the variable _button in your class declaration.

Try this:
interface ICaseStageTransitionControlView: IControlView
{
    Button PassButtonToControl { get; set;}
}

public partial class CaseStageTransitionControl : ICaseStageTransitionControlView
{
    public Button PassButtonToControl { get; set; }
}

讨论:这假定您已经正确地实现了IControlView接口所需的一切.

Discussion: This assumes that you''ve done the right thing to implement whatever the IControlView interface requires.


在许多情况下,显式接口实现比Bill所示的形式更好:


In many cases, explicit interface implementation is better then the form shown by Bill:


public interface ICaseStageTransitionControlView : IControlView
{
    Button PassButtonToControl { get; set;}
}

public partial class CaseStageTransitionControl : ICaseStageTransitionControlView
{
    Button ICaseStageTransitionControlView.PassButtonToControl { get; set; }
}



有关更多详细信息,请参见:
http://msdn.microsoft.com/en-us/library/aa288461%28v = vs.71%29.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/ms173157.aspx [ ^ ].


另请参见:
http://blogs.msdn.com/b/mhop/archive/2006/12/12/implicit-and-explicit-interface-implementations.aspx [ http://adilakhter.wordpress.com/2007/05/02 /explicit-interface-implementation-using-c-interface101/ [



For further detail, please see:
http://msdn.microsoft.com/en-us/library/aa288461%28v=vs.71%29.aspx[^],
http://msdn.microsoft.com/en-us/library/ms173157.aspx[^].


See also:
http://blogs.msdn.com/b/mhop/archive/2006/12/12/implicit-and-explicit-interface-implementations.aspx[^],
http://adilakhter.wordpress.com/2007/05/02/explicit-interface-implementation-using-c-interface101/[^].

—SA


也尝试实现IControlView接口的成员,因为您已经将该接口继承到当前接口.
Try to implement the members of the IControlView interface too as you have inherited that interface to the current interface.


这篇关于实施接口时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆