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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:45:27+00:00 2026-05-25T01:45:27+00:00

Possible Duplicate: How do I create a list of objects that inherit from the

  • 0

Possible Duplicate:
How do I create a list of objects that inherit from the same generic class with varying types?

I’m using several objects where they are inherited from an abstract class. But to use the abstract class must be declara a generic datatype.

I’m having problems because I need to have a list where contains a list of ProblemBase, although each one contains a different TResult datatype.

public abstract class ProblemBase<TResult>
{
    TResult[] Array;
}

And I want to get Array property. That’s the problem.

  • 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-25T01:45:27+00:00Added an answer on May 25, 2026 at 1:45 am

    This type of thing happens for me quite often. The solution I typically go with is to have a base class for ProblemBase<T> that is type free:

    public abstract class ProblemBase
    {
        public abstract object Result { get; }
    }
    
    public abstract class ProblemBase<TResult> : ProblemBase
    {
        public override object Result
        {
            get { return Result; }
        }
    
        new public TResult Result { get; private set; }
    }
    

    Whenever you need a collection of problems, then, you can make a collection of ProblemBase without the generics.

    If TResult has its own required inheritance hierarchy, then you can do this instead:

    public abstract class ProblemBase
    {
        public abstract ResultBase Result { get; }
    }
    
    public abstract class ProblemBase<TResult> : ProblemBase
        where TResult : ResultBase
    {
        public override ResultBase Result { get { return Result; } }
        new public TResult Result { get; private set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do I Create a Comma-Separated List using a SQL Query? I
Possible Duplicate: How to create comma separated list from array in PHP? I have
Possible Duplicate: Global variables in Java How to create a list of global variables
Possible Duplicate: most elegant way to return a string from List<int> I'm not sure
Possible Duplicate: Create a date with T-SQL I've a data table that stores each
Possible Duplicate: How to create ArrayList (ArrayList<T>) from array (T[]) in Java How to
Possible Duplicate: How to determine the class of a generic type? I have a
Possible Duplicate: Create WPF TextBox that accepts only numbers How i can check if
Possible Duplicate: Concat all strings inside a List<string> using LINQ I am using C#
Possible Duplicate: <: cannot begin a template argument list Did you know that int

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.