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

The Archive Base Latest Questions

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

I have an abstract class as defined here: public abstract class BaseClientService<T> where T

  • 0

I have an abstract class as defined here:

public abstract class BaseClientService<T>
    where T : ISubsetInfo
{
    abstract T Extract(Superset superset);
}

This works well for all of my implementation, but now I am faced with an implementation that needs an additional argument in order to perform correctly.

eg

T Extract(Superset superset, int id)    

I’m trying to find the most elegant solution, so am trying to avoid including the second argument as either nullable or optional, but I’m not sure if it is worth the effort…

I also though about wrapping the arguments in an object, and having that object include the id for the edgecase, but I think its making it more complex where I’m trying to make it simpler.

The important constraint for me is that I always have one method to call in the abstract class.

  • 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-28T06:52:04+00:00Added an answer on May 28, 2026 at 6:52 am

    The solution I went for in the end was to introduce a new generic object to my design called Requirement which would be used to identify additional requirements for the operation:

    public abstract class BaseClientService<T, R>
    where T : ISubsetInfo
          R : IRequirement
    {
        abstract T Extract(R requirement);
    }
    

    This solution is much like Dialecticus’s proposal, but I prefer this one as my requirement is strongly typed. One could argue the overuse of Generics here, but now that it is in my project, its working like a charm.

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

Sidebar

Related Questions

Let's say I have defined the following class: public abstract class Event { public
Suppose we have abstract class A (all examples in C#) public abstract class A
Let say I have abstract class called: Tenant and Customer. The tenant in this
I have an abstract base class with a TcpClient field: public abstract class ControllerBase
I have an abstract class: type TInterfaceMethod = class abstract public destructor Destroy; virtual;
I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor
I've got an abstract class defined by another assembly (not editable): public abstract class
Let's say I have an abstract class: abstract class Foo extends Bar { public
So I have this class public static class MyClass { static MyClass() { ...
<?php abstract class file { private $pid; private $uid; public function __construct($pid,$uid) { $this->pid

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.