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 8330669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:11:23+00:00 2026-06-09T02:11:23+00:00

Possible Duplicate: Interfaces: Why can't I seem to grasp them? to work with a

  • 0

Possible Duplicate:
Interfaces: Why can't I seem to grasp them?

to work with a library I just found I need to implement a few interfaces first. But some methods seem to be asking for objects that have the type of some interfaces…
And if I have an interface called MyInterface I can write things like :

    MyInterface shoe;

It does not really make sense to me. Can somebody teach me this concept ?
I read this : http://www.dotnetperls.com/interface but it did not really help, I think this concept is a bit more complex than what is presented here.

Thanks !

edit :

For those who wonder, I am not new to Interfaces but it is the first time I ran into such a use of them. And for those downgrading my question, I did search but was unlucky apparently.

  • 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-06-09T02:11:25+00:00Added an answer on June 9, 2026 at 2:11 am

    You can declare an Interface, like in your example. However you can not instantiate one.

    MyInterface shoe = new MyInterface ();
    

    The above is not legal code. Since an Interface just describes a contract, it has no implementation details, this is left to the client code (you). Therefore it makes no sense to be able to create actual instances of MyInterface.

    What you can do, is have a class SomeClass, implement the MyInterface contract:

    SomeClass: MyInterface
    {
      //implement the methods of MyInterface. All of them, to fulfill the contract.
    }
    

    Then you can do things like:

    MyInterface shoe = new SomeClass();
    

    Since SomeClass implements the MyInterface contract, the above is legal. You can create an instance of SomeClass because it contains implementation details.

    Then you can build on this and create more classes which implement MyInterface.

    The beauty of this is that you can have a method for example:

    void someMethod (MyInterface test)
    {
    
    }
    

    You can pass this method the SomeClass object or any other class you created which implements MyInterface.

    Then inside this method, you can call methods that the contract contains without knowing the exact object which has been passed to you. This makes writing future code easier. You can create new objects and so long as they implement MyInterface, it is valid to pass this object to someMethod without changing the declaration of the method.

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

Sidebar

Related Questions

Possible Duplicate: Interfaces: Why can't I seem to grasp them? I have seen many
Possible Duplicate: WHY an Anonymous class in Java can't implement multiple interfaces directly? Simply
Possible Duplicate: Can I overload an == operator on an Interface? I do understand
Possible Duplicate: Ternary Expression with Interfaces as a Base Class Classes: interface ISms {
Possible Duplicate: Is there a reason you can not define the access modifier on
Possible Duplicate: Interface vs Base class A class implementing an interface has to implement
Possible Duplicate: Haskell vs. procedural programming in the real world Few times I heard
Possible Duplicate: Java Interfaces? What is the use of interface in java? Is interface
Possible Duplicate: Protected in Interfaces The following code snippet shows that an interface in
Possible Duplicate: Can C# be piped? Is there a way to connect two programs

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.