未实现接口成员的问题 [英] Does not implement interface member issues

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

问题描述

我有:

public interface ITest
{
    string test { get; set; }
}

[DataContract]
public class TestGeneric : ITest
{
    [DataMember]
    public string test;
}



不过,我不断收到错误:'TestGeneric在公共类TestGeneric对 TestGeneric 不实现接口成员'ITest.Test:ITEST 的代码行。会有人能够解释这是为什么?

But i keep getting the error: 'TestGeneric' does not implement interface member 'ITest.Test' on TestGeneric in the public class TestGeneric : ITest line of code. Would someone be able to explain why this is?

推荐答案

您已经创建了一个领域,因为你忽略了 {搞定;组; } 访问,使成员的属性。

You have created a field, as you omitted the { get; set; } accessors that make a member a property.

的实施必须在接口完全相同的访问匹配,所以加:

The implementation must match the interface exactly, so add those accessors:

public class TestGeneric : ITest
{
    public string Test { get; set; }
}

这篇关于未实现接口成员的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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