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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:31:09+00:00 2026-05-26T22:31:09+00:00

I have a generic interface, and a few classes implement it. then from a

  • 0

I have a generic interface, and a few classes implement it.
then from a global place, I want to use methods from that interface,
yet, I don’t know their compiled generic type, so the reference is only their object’s class, as showing in runtime. (so I can’t get access to the interface methods)

a few questions:

  1. Is it possible to use them?
  2. should I design it without generics?
  3. what is the purpose of generic interfaces if I can’t use them at runtime?
  4. can generics out/in or dynamic help in that situation?

edit: some example code

  public interface IMyInterface<T> 
        where T: class, new()
    {
        void Delete (T obj);
    }

public class trigger {}
public class triggervm : IMyInterface<trigger>
{

List<trigger> _trigList = new List<trigger>()
    public void Delete (trigger obj)
    {
        _trigList.Remove (obj);
    }
}

now, say I want to check, and then use the method Delete, from a “global” place:

if (chosenItem is IMyInterface<???>)
{
     var item = chosenItem as      IMyInterface<???>;
     item.Delete(someObj);
}
  • 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-26T22:31:10+00:00Added an answer on May 26, 2026 at 10:31 pm

    like thomas suggested, I use dynamic,

    and like “RedHat” suggested, I have the enclosing class inherit from both my interface (IClipboard<T>) and a parent interface (IClippable) that is just a “grouping” interface.

    myinterface inherits from the grouping interface, so any class that implements myinterface also matches the grouping one.
    so I can check if the selected item is IClippable.

    the cleanest I could get with my current knowledge of the language.

    better support in C# would be nice.

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

Sidebar

Related Questions

I have a few generic classes that implement a common non-generic interface. I create
I have an Interface called as IObSrc, I have few classes that implement this
I want to have a generic object that implements an interface. I mean if
I have an interface, IFindable that is implemented by a few classes. One other
I have a bunch of generic interfaces and classes public interface IElement { //
I have an interface that contains a single method called ListAll() using System.Collections.Generic; namespace
I have a generic interface, say IGeneric. For a given type, I want to
i have a few classes that i am trying to move to using generics
I have a Generic Type Interface and want a constructor of an object to
I have one generic interface in c#, and almost always I use it with

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.