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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:55:41+00:00 2026-05-11T07:55:41+00:00

So I am utilizing CollectionBase as an inherited class for custom collections. I am

  • 0

So I am utilizing CollectionBase as an inherited class for custom collections. I am utilizing CollectionBase through an abstract class so that I don’t repeated knowledge (following the DRY principle). The abstract class is defined as a generic class also. Here is how I am implementing my class:

 public abstract class GenericCollectionBase<T,C> : CollectionBase  {       //Indexders, virtual methods for Add, Contains, IndexOf, etc  } 

I utilize this so I don’t have to implement these base methods in 10+ classes.

My question is am I taking this too far when I override the Equals method like this:

    public override bool Equals(object obj)     {         if (obj is C)         {             GenericCollectionBase<T, C> collB =                  obj as GenericCollectionBase<T, C>;              if (this.Count == collB.Count)             {                 for (int i = 0; i < this.Count; ++i)                 {                     if (!this[i].Equals(collB[i]))                         return false;                 }                 return true;             }         }         return false;     } 

Am I trying to accomplish too much with my abstract, or doing this the correct way?

EDIT: This is written for .Net 2.0 and do not have access to 3.5 to utilize things like LINQ

  • 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. 2026-05-11T07:55:41+00:00Added an answer on May 11, 2026 at 7:55 am

    I don’t believe you are trying to accomplish too much. If an abstract class was meant to not have any implementation at all, or other methods which define functionality, then they would be interfaces.

    The only thing I would change is to use EqualityComparer<T> instead of equals for the comparison of this[i] and collB[i].

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

Sidebar

Related Questions

Utilizing .Net I am inheriting from an older class that has DateTime and bool
Is there any way (utilizing Reflection I hope) that I can make an instantiated
I'm relatively new to utilizing web services. I'm trying to create one that will
I have a page that is currently utilizing a jQuery plug-in for truncating text
I have ZF app that is utilizing a legacy Javascript at for some functionality.
We have some services utilizing SunRPC on Linux (RHEL 4/5) that we'd like to
i have some problem with utilizing TLF, i need to parse through the text
I have a client that's utilizing a windows service I wrote that polls a
The app makes calls (utilizing HttpPost) to a PHP files that sends a queries
I'm utilizing some network share folders as part of my program. I realized that

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.