C# 实现接口时出错:类不';t实现接口成员

C# 实现接口时出错:类不';t实现接口成员,c#,visual-studio,visual-studio-2010,azure,azure-web-roles,C#,Visual Studio,Visual Studio 2010,Azure,Azure Web Roles,我正在尝试实现IUpdatable 错误1“WebRole1.InfoManager”未实现接口成员“System.Data.Services.IupDataable.ClearChanges()” 我得到的所有错误都表明我没有实现所有接口成员,但我实现了一些,当然不是全部。我没有把洞的密码,我希望你能理解 using System; using System.Collections.Generic; using System.Linq; using System.Web;

我正在尝试实现IUpdatable

错误1“WebRole1.InfoManager”未实现接口成员“System.Data.Services.IupDataable.ClearChanges()” 我得到的所有错误都表明我没有实现所有接口成员,但我实现了一些,当然不是全部。我没有把洞的密码,我希望你能理解

  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Data.Services;
  using Microsoft.WindowsAzure;
  using Microsoft.WindowsAzure.ServiceRuntime;
  using Microsoft.WindowsAzure.StorageClient;

  namespace WebRole1
  {
     public class InfoManager : IUpdatable
     {
      private TableServiceContext context;

    // To Generate DataConnectionString and svcClient
    private TableServiceContext GetContext()
    {
    //Implemented code
    }

    public CommentManager()
    {
        context = GetContext();
    }


    // To get my table infos
    public IQueryable<Info> Infos
    {
        get
        {
            return context.CreateQuery<Info>("Infos").AsTableServiceQuery();
        }
    }
   // Creating the resource and cheking the compatibility of the type and do an add Object 

    public Object CreateResource(string containerName, string fullTypeName)
    {
        //Implemented Code
    }

    // Return the instance of the resource represented by the object 
    public Object ResolveResource(Object resource)
    {
        return resource;
    }

    public void SaveChanges()
    {
        context.SaveChangesWithRetries();
    }

    public void setValue(Object targetResource, string propertyName, Object propertyValue)
    {
    //Implemented Code
    }

}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用系统、数据、服务;
使用Microsoft.WindowsAzure;
使用Microsoft.WindowsAzure.ServiceRuntime;
使用Microsoft.WindowsAzure.StorageClient;
命名空间WebRole1
{
公共类InfoManager:IUpdatable
{
私有表服务上下文上下文;
//生成DataConnectionString和SVCLIENT的步骤
私有表ServiceContext GetContext()
{
//实现代码
}
公共事务经理()
{
context=GetContext();
}
//获取我的餐桌信息
公共可查询信息
{
得到
{
返回context.CreateQuery(“Infos”).AsTableServiceQuery();
}
}
//创建资源并检查类型的兼容性,然后执行add对象
公共对象CreateResource(字符串containerName、字符串fullTypeName)
{
//实现代码
}
//返回由对象表示的资源的实例
公共对象资源(对象资源)
{
返回资源;
}
公共void SaveChanges()
{
context.SaveChangesWithRetries();
}
public void setValue(对象targetResource、字符串propertyName、对象propertyValue)
{
//实现代码
}
}

}我不明白问题是什么。如果实现接口,则必须实现该接口中的所有方法。否则编译器将给出一个错误。

这是一个接口,因此您必须实现所有成员,无论您是否愿意

在您完整实现接口之前,此错误不会消失。你可以在你正在实现的方法的范围内做你想做的事情,比如说甚至提出一个
NotImplementedException
,但是这是你的实现,所以编译器很高兴

我不会宽恕无知(你仍然应该学习如何和为什么),但我会提供一个提示,这可能有助于你的学习,如果没有其他帮助的话,还有助于未来的生产力:

在VisualStudio中,当您打开用于实现接口的类代码文件时,您可以让VS为您吐出代码

class MyClass : IMyInterface // <- hover mouse and click the drop down that appears

classmyclass:IMyInterface/我认为错误很明显:您没有实现所有接口成员,这当然是必需的。

好的,如果我只需要一些方法,我可以提出NotImplementedException,这会更快,谢谢。虽然这肯定是正确的方法,但这并不是一个好习惯。作为一名同事,我总是会问,为什么要实现一个没有所有方法的接口。你基本上是在撒谎,除非接口规定这样的实现是允许的。如果你想快速,请查看我的自动生成更新。如果您想手工操作,那么定义方法体并省略任何异常引发将比添加
抛出
@404Dreamer\u ML Yes更快。除非您实现所有方法,否则它将给出错误。这就是实现接口的含义,即实现接口的所有方法。