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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:51:29+00:00 2026-05-26T19:51:29+00:00

I have to develop a custom collection of objects. The reason is two fold,

  • 0

I have to develop a custom collection of objects. The reason is two fold, I need to be able to assign an internal name to the collection and the collection also needs to implement some abstract methods to be treated like any other entity that I have.

So I created an EntityList class. Below is a snippet of the class. It contains a id and a list of entities, plus a bunch of methods. My question is this, so far I have put in the list management methods that I require, such as Add, Insert, Remove and Clear. If you have an EntityList reference called myEntityList you could perform something like myEntityList.Add(newEntity). I do like this approach, but really these methods are just handing off the work to the list. I could also not implement any of these methods and you could perform the same action as above by using myEntityList.Items.Add(newEntity). However, here you are directly accessing a method of a property of the object. I wanted to remove the Items property altogether, however I often need to iterate through the list using a foreach and for that I need access to the actual list.

Here is my class definition, it does not have the overrides to the abstact methods included.

class EntityList
{
    String entityId;
    List<EntityBase> _entities;

    public EntityList()
    {
        _entities = new List<EntityBase>();
    }

    public List<EntityBase> Items
    {
        get { return _entities; }
        //set { _entities = value; }
    }

    public void Add(EntityBase entity)
    {
        _entities.Add(entity);
    }

    public void Insert(int index, EntityBase entity)
    {
        _entities.Insert(index, entity);
    }

    public void Remove(EntityBase entity)
    {
        _entities.Remove(entity);
    }

    public void Clear()
    {
        _entities.Clear();
    }
}

Am I violating some cardinal rules here? How should I manage the list when it is a member of another class?

  • 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-26T19:51:29+00:00Added an answer on May 26, 2026 at 7:51 pm

    Just inherit from List<EntityBase> then you won’t need to redeclare and implement the list methods.

    i.e.

    class EntityList : List<EntityBase>
    {
       String entityId;
       //add your extra methods.
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the need to develop a custom HttpHandler in SharePoint. To start, I
I have used sendinput() function and windows keyboard hooks to develop a custom keyboard
I have a number of custom objects of type X. X has a number
I need to develop custom software to do surveys. Questions may be of multiple
i have a special question i really want to learn how to develop custom
I develop a custom control that have some field like below: ControlKind, Field1 ,
I have a requirement to develop a custom control for use in InfoPath 2010
We have a new client who would like us to develop a custom CRM
I have a winforms project that I want to develop a custom control for.
I am trying to develop an iPad app in which I need to have

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.