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

  • Home
  • SEARCH
  • 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 7496121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:29:35+00:00 2026-05-29T18:29:35+00:00

Hi how do we implement interface in a real time scenario?? This is my

  • 0

Hi how do we implement interface in a real time scenario??

This is my situation

I have made an interface IPayPal which has 2 methods

void SaleTransaction();
void VoidTransaction();

now i have a class PayPal which implements this service.

class PayPal:IPayPal{

    public void SaleTransaction(){
    // Implementation happens here

    }

    public void VoidTransaction(){
    // Implementation happens here

    }



}

now i have a service that requests the services from PayPal

lets say

class Service{

IPayPal pp=null;


static void Main(){

    pp=new PayPal();
    //Now i do not want to expose all the methods in my class PayPal 
    // is there any other way to just show pp.SaleOneTransaction() method?? i donot want the //PayPal class to be present in this Program..

    //Please tell me how to acheive this.
    }

}

i.e Please tell me a way in which i can initialise my interface class without revealing the class that implements the interface.

Thanks

  • 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-29T18:29:42+00:00Added an answer on May 29, 2026 at 6:29 pm

    I would suggest:

    1. read about dependency injection and how it can help you resolve dependencies easily and in a loose coupled way.
    2. the interface name “IPayPal” is not very good name IMHO. It is very specific to one payment provider. Suppose tomorrow you want to implement another payment method that is not paypal, yet you want to use the same interface. I think the name should be generic like “IPaymentProvider”, and the current implementation is PayPal (but no other class using that interface should care or know about this).

    good luck!

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

Sidebar

Related Questions

Is it possible to have an anonymous type implement an interface? I've got a
If I have a class that needs to implement an interface but one or
I have an abstract base class which acts as an interface. I have two
I have been struggling with this for some time now scanning the net for
I've got an interface inheritance issue that has been vexing me for some time.
I have generated an Interface which is very well documented. Every method does have
I have 2 components (AWriter and BWriter) where both implement IWriter interface. And I
I am looking to use Facebook's Graph API to implement real-time updates . My
I'm constantly using the Implement interface shortcut in Visual Studio 2008. My problem is
If I implement an interface on a base class will it be inherited by

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.