Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when Implementing Interface: class doesn't implement interface members

I am trying to implements the IUpdatable.

Error 1 'WebRole1.InfoManager' does not implement interface member 'System.Data.Services.IUpdatable.ClearChanges()' All the errors i get are saying that i am not implementing all interface members, but i implements some not all of course. I didn't put the hole code I hope that you can understand.

  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
    }

}

}

like image 957
404Dreamer_ML Avatar asked Jun 27 '26 17:06

404Dreamer_ML


2 Answers

It's an interface, therefore you MUST implement all members - whether you want to, or not.

This error will not go away until you implement the interface in its entirety. You can do what you want within the scope of the method you're implementing, say even raising a NotImplementedException for instance - but that is your implementation so the compiler is happy.

I won't condone ignorance (you should still learn the hows and whys) but I will offer a tip which may aid in your learning and, if nothing else, future productivity:

From within Visual Studio, when you have the class code file open which is to implement the interface then you can have VS spit out the code for you...

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

From the drop down you should see the option Implement Interface 'IMyInterface', click it and voilà! It will automatically generate the skeletal method bodies for you.

like image 188
Grant Thomas Avatar answered Jun 29 '26 07:06

Grant Thomas


I don't understand what the question is. If you implement an interface, you must implement all methods in that interface. Otherwise the compiler will give an error.

like image 44
jdmichal Avatar answered Jun 29 '26 07:06

jdmichal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!