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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:31:05+00:00 2026-06-10T13:31:05+00:00

I got a class public class ID_Name<T> { public ID_Name(T id) { this.ID =

  • 0

I got a class

public class ID_Name<T>
{
    public ID_Name(T id)
    {
        this.ID = id;
    }

    public T ID { get; set; }

    public string Name
    {
        get 
        {
            return Helper.SomeReturnValue;            
        }
    }
}

All I want to do is generate a custom List of ID_Name where I can pass an ID_Name.ID as parameter in Add.
I tried the following:

public class ID_Name_List<T> : IList<T> where T : ID_Name<T>

but then I get the following error:

The type “EProtokollStatus” cannot be used as type parameter “T” in
the generic type or method “ID_Name_List<\T>”. There is no boxing
conversion or type parameter conversion from “EProtokollStatus” in
ID_Name<\EProtokollStatus>.

I read something about this issue here: No boxing or type parameter conversion for generic Type parameter but I can’t see a restriction except ID_Name here.
This may be wrong somehow, because everything I want to express is “use the same type T as in ID_Name for ID_Name_List”, but how do I achieve that?

I found something here: C#: Declaring and using a list of generic classes with different types, how? but I don’t want to create many different classes for all possible types.

All I want to achieve is something like

ID_Name_List<EProtokollStatus> myList = new ID_Name_List<EProtokollStatus>();
myList.Add(EProtokollStatus.ValueX);
  • 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-10T13:31:06+00:00Added an answer on June 10, 2026 at 1:31 pm

    Your current constraint makes no sense. Did you mean:

    public class ID_Name_List<T> : IList<ID_Name<T>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this class: class Foo { public string Name { get; set; }
Say we've got a class like public class Doer { public int Timeout {get;set;}
I've got a class, like this, simplified: public class Bookmark { public string Nav
I've got this Venue object: public class Venue { public int Id { get;
I've got the following class: public static class Pages { public static string LoggedOut
I got a problem class a { public $aa=1; public function dd(){ $this->aa =
I've got a mapping file like this: <class name=Resource table=resource discriminator-value=null> <composite-id name=Key class=Models.Bases.ClientKey,
I've got a class Column public class Column { public int Id { get;
I got this simple class hierarchy; public class A { [Key] public int Id
I've got a object (Filter) that's defined something like this public class Filter {

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.