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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:49:43+00:00 2026-05-12T19:49:43+00:00

I have a feeling I already know the answer people are going to give,

  • 0

I have a feeling I already know the answer people are going to give, but here goes anyway:

Say I’m writing a new class, let’s call it PooledQueue<T>, in the constructor of which I want to accept an argument that implements the interface IResourcePool<T>. The idea here is that I’m fine with using any underlying pool object, as long as it gives me the properties/methods of IResourcePool<T> (you know, the whole idea behind interfaces, right?).

But if there’s already a class available that provides all the functionality of IResourcePool<T>, except that it doesn’t implement IResourcePool<T> (and I can’t modify the source code), is there any way for me to force the implementation?

What I’m expecting people to answer is that I should just make a wrapper for the existing class that does implement the necessary interface. But I’d just prefer to be able to do this:

// GetDataPool returns an object of type Pool<Data> that I can't modify
var q = new PooledQueue<Data>(GetDataPool());

instead of this:

var q = new PooledQueue<Data>(new PoolWrapper<Data>(GetDataPool()));

I guess what I feel would be really useful is if a class’s implementation of an interface could be defined separately from the class definition. Sort of the way a well-designed database is structued–with association tables linking entities with IDs from other tables. Does that make sense?

  • 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-12T19:49:43+00:00Added an answer on May 12, 2026 at 7:49 pm

    Out of the box, you cannot force an interface on a class without inheriting from it.

    There are ways, such as using a transparent RealProxy or 3rd-party libraries such as LinFU, which allow you to simulate stuff like this, but at a higher cost than making your wrapper class.

    In fact, you could make an overload constructor which creates the wrapper for you, so that the code stays clean…

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

Sidebar

Related Questions

I have a feeling I may already know the answer to this question, but
I have a feeling that I already know the answer to this one, but
I have a feeling I'm going about this all wrong. But anyway. I have
I have a feeling this has already been answered, but I don't know the
I have the feeling the answer to this question is no but I figured
I have a feeling I'm asking a stupid question here. I'm having trouble retrieving
I have a feeling this is a stupid question but I can't find the
I have a feeling I am completely borking this MySQL query but I'll ask
I have a feeling that I am going to ask a stupid question, yet
I have a feeling someone is going to point me to another question that

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.