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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:34:05+00:00 2026-06-13T20:34:05+00:00

Each inherited class’s method need different type of parameter. In this case, how should

  • 0

Each inherited class’s method need different type of parameter.
In this case, how should I define parameter in Interface Method to able to all children method can accept?

public interface IPayment 
{
  void MakePayment(OrderInfo orderInfo); // !!
  void MakeRefund (OrderInfo orderInfo); // !!
}

public class OrderInfo 
{
  protected string OrderNo {get; set;}
  protected string CustomerNo { get; set;}
  protected decimal Amount {get; set;}
}

public class CreditCardPaymentInfo : OrderInfo
{
  string CCNum {get; set;}
  string ExpDate { get; set;}
}

public class GooglePaymentInfo : OrderInfo
{
  string GoogleOrderID {get; set;}
}

public class PaypalPaymentInfo : OrderInfo
{
  string PaypalID {get; set;}
}



public void MakePayment()
{
    IPayment paymentModule;
    // Get Order Info 
    if(orderType == "Paypal"){
        paymentModule = new PaypalPayment();

        PaypalPaymentInfo orderInfo = new PaypalPaymentInfo();
        orderInfo.PaypalID = "TEST";
    }else if(orderType == "Google"){
        paymentModule = new GooglePayment();

        GooglePaymentInfo orderInfo = new GooglePaymentInfo();
        orderInfo.GoogleOrderID = "TEST";
    }else{
        paymentModule = new CreditCardPayment();

        CreditCardPaymentInfo orderInfo = new CreditCardPaymentInfo();
        orderInfo.CCNum = "1111111111111111";
        orderInfo.ExpDate = "11/11";
    }

    orderInfo.OrderNo = "123";
    orderInfo.CustomerNo = "ABC";
    orderInfo.Amount = 12.20m;

    paymentModule.MakePayment();
}

It occur an error :

Error 1 ‘com.WebUI.Models.CreditCardPaymentInfo’ does not implement interface member ‘com.WebUI.Models.IPaymentProcess.makeRefund(WebUI.Models.RefundModel)’

[Edit]

Oh I forgot my Model Code, it’s like this,

public class CreditCardPayment: IPayment 
{
  public void MakePayment(CreditCardPaymentInfo creditCardPaymentInfo ){...}
  //The parameter type is NOT OrderInfo 
  //public void MakePayment(OrderInfo orderInfo){...}
  public void MakeRefund(CreditCardPaymentInfo creditCardPaymentInfo ){...}
}

but in CreditCardPayment case, I need to pass CreditCardPaymentInfo parameter not OrderInfo that only contain for common fields.

  • 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-13T20:34:06+00:00Added an answer on June 13, 2026 at 8:34 pm
    public interface IPayment<T> 
        where T: OrderInfo
    {
      void MakePayment( T orderInfo );
      void MakeRefund ( T orderInfo );
    }
    

    Then:

    public class CreditCardPayment
        : IPayment<CreditCardPaymentInfo>
    {
        public void MakePayment( CreditCardPaymentInfo creditCardPaymentInfo ) {
            // ...
        }
    
        public void MakeRefund( CreditCardPaymentInfo creditCardPaymentInfo ) {
            // ...
        }
    }
    

    And:

    public class CreditCardPaymentInfo
        : OrderInfo
    {
        public string CCNum { get; set; }
        public string ExpDate { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SalesOrder class which is inherited by several different types of sales
I need to have lazyload logic for creating mappers in my class. Each mapper
I have set of classes. Each class is inherited from another class. The relationship
I have a class inherited from UITableViewController and this is also the root class.
We've inherited large legacy application which is structured roughly like this: class Application {
Is it possible in Delphi to have a class method invoke an inherited instance
Each time I use Merge() I have the following: 'Cannot implicitly convert type 'void'
Each key in dictionary has list of MANY integers. I need to iterate through
Each of of these threads is searching through a different list of data objects
I have an abstract class BaseItem declared like this: public abstract class BaseItem {

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.