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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:18:37+00:00 2026-05-22T20:18:37+00:00

I have an abstract class that other classes are inheriting this. public abstract class

  • 0

I have an abstract class that other classes are inheriting this.

public abstract class GenericAccess<TEntity>
{
    public static IList<TEntity> GetObjectListFromArray(int[] IDs)
    {
        //Your help need is here.
    }
}

public class Doors : GenericAccess<DoorEntity>
{

}

public class DoorEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
}

I need to create a generic method so when I can for example

IList<DoorEntity> Doors.GetObjectListFromArray(int[] {1,2,3,4,5});

it will return an IList having all the objects in it with the property Id loaded with the value passed. In the above example it will return a list with 5 items in the list with the Id of DoorEntity loaded.

  • 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-22T20:18:38+00:00Added an answer on May 22, 2026 at 8:18 pm

    Use an interface or a base class…

    With interface:

    public abstract class GenericAccess<TEntity> where TEntity : IEntity, new()
    {
        public static IList<TEntity> GetObjectListFromArray(int[] IDs)
        {
            return IDs.Select(id => new TEntity { Id = id }).ToList();
        }
    }
    
    public class Doors : GenericAccess<DoorEntity>
    {
    
    }
    
    public class DoorEntity : IEntity
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    
    public interface IEntity
    {
        int Id { get; set; }
        string Name { get; set; }
    }
    

    With a base class:

    public abstract class GenericAccess<TEntity> where TEntity : Entity, new()
    {
        public static IList<TEntity> GetObjectListFromArray(int[] IDs)
        {
            return IDs.Select(id => new TEntity { Id = id }).ToList();
        }
    }
    
    public class Doors : GenericAccess<DoorEntity>
    {
    
    }
    
    public class DoorEntity : Entity
    {
    
    }
    
    public abstract class Entity
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an abstract class that is inherited by a number of other classes.
I have an abstract class Employee and 2 other classes that extend it (Developer
I have this abstract class that is used as data repository. public abstract class
I have a singleton class that implements two other abstract classes. My monkey::getMonkey fails
I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor
I have an abstract base class that holds a Dictionary. I'd like inherited classes
I have a abstract base class that I have many inherited classes coming off
I have a class that inherits from Page, called APage. public abstract class APage:
If I have a base class such that public abstract class XMLSubscription <T extends
I have an Abstract class called Function which has 2 inheriting classes (actually 6,

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.