Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7412039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:28:47+00:00 2026-05-29T06:28:47+00:00

I’ve just been handed an API that seems to be a step up from

  • 0

I’ve just been handed an API that seems to be a step up from what I’m used to, as everything appears to be implemented using interfaces, and I’m struggling to get my head around them.

public partial class Form1 : Form, IFoo
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Guid jobID = AddBarToFoo(fooID, barPath);
    }

    public Guid IFoo.AddBarToFoo(string fooID, string barPath)
    {
        throw new NotImplementedException();
    }

So that’s a basic structure. Visual Studio has kindly implemented the interface in its entirety and I can call the AddBarToFoo method. Great.

But now what? Evidently the method is a void that requires some code, but what code? Should I be scouring the API for objects to instantiate with that method? Or am I going down completely the wrong path?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:28:48+00:00Added an answer on May 29, 2026 at 6:28 am

    That’s the thing with interfaces. They only define how someone will call them. They say absolutely nothing about what the method should really do, or how it should do it. That’s up to the person implementing the interface to decide.

    VS “implements” the method by adding the single line throw new NotImplementedException(); which is really just to satisfy the compiler.

    Here’s two possible (contrived) implementations that do totally different things. Both implement IFoo:

    public class DbFoo:IFoo {
        public Guid IFoo.AddBarToFoo(string fooID, string barPath) {
            // this might add a Foo to the database and return its Guid
        }
    }
    
    public class ListBasedFoo:IFoo {
        public ListBasedFoo() { MyList = new List<Foo>(); }
    
        public List<Foo> MyList { get; private set; }
    
        public Guid IFoo.AddBarToFoo(string fooID, string barPath) {
            // this could add a Foo to MyList, and return some Guid to reference it
        }
    }
    

    Edit… You’ll see interfaces used a lot in places where the abstract behavior is important, but the implementation can vary. For instance, an interface to persist objects. During development you might want to use a mock that puts and gets items into a list in memory. Later you might use an interface that directly hits a database via ADO .NET or Entity Framework or LINQ to SQL. Maybe at another point in the application’s lifetime a new implementation would be dropped in that uses WCF web services instead.

    The point in my above example is that the calling code won’t break. The interface is satisfied – only the behavior has been changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.