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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:02:48+00:00 2026-06-04T12:02:48+00:00

I am working on a utility that will have an interface for Filters with

  • 0

I am working on a utility that will have an interface for “Filters” with a number of implementations of that interface. Part of the interface will return an object of type Control that will be used in a UI for manipulating the filters.

I would like to be able to require that the returned control also implement another interface so that I can do things like request that the controls write back to the object that created them.

right now my code looks like:

public interface IFilter
{
    Control Control();
}

I would like someting like:

public interface IFilterControl
{
    ...
}

public class FilterControl : Control, IFilterControl{}

public interface IFilter
{
    ...
    FilterControl Control();
}

The above does not work because FilterControl does not actually implement IFilterControl.

If the above is not clear enough try to visualize how the imaginary keyword “implmenting” would work below

public interface IFilterControl
{
    IFilter Filter{get;}
}

public interface IFilter
{
    Control implmenting IFilterControl Control();
}

public interface FilterImpl : IFilter
{
    Control implmenting IFilterControl Control(){
        return new FilterControlImpl(this);
    }
}

public partial class FilterImplControl : UserControl, IFilterControl
{
    FilterImpl filter;
    public FilterImplControl(FilterImpl filter)
    {
        this.filter = filter;
    }

    public IFilter Filter{get{return filter;}}
}


FilterImpl a_filter = GetAFilter();
Control implmenting IFilterControl ctl = a_filter;
panel.Controls.Add(ctl);
FilterImpl the_filter_indirectly = ctl.Filter;
  • 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-04T12:02:49+00:00Added an answer on June 4, 2026 at 12:02 pm

    Might want to look at using generics. They’ll let you place constraints on the type.

    public interface IFilter<T> where T : Control
    {
        T Control { get; set; }
        T ControlMethod();
    }
    

    The where clause is a generic restraint and will require that T is always of type Control. It works for interfaces as well. That way, you know those methods or properties are always a derivative of Control and those expectations will show up in intellisense.

    EDIT
    Oh, just occurred to me that you can apply the generic solely at the method if you’d prefer.

    interface IFilter
    {
        T Control<T>() where T : Control;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a utility that will be used to test the project I'm
I'm working on a utility that will auto mount an inserted USB stick on
I'm working on a utility that will scan USB ports and mount any Mass
I am working on a simple notification service that will be used to deliver
I am working on a JavaScript utility that tells the user the number of
I'm currently working on a C++ project that needs to have as few external
I am working on a C# based application in which I have a utility
I have an android app that appears to be working fine - but I
So, I am working on a Linux based command line utility, that has to
I am working on an open source backup utility that backs up files and

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.