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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:46:14+00:00 2026-05-27T03:46:14+00:00

I have a base object abstract class and a base object collection class for

  • 0

I have a base object abstract class and a base object collection class for some business objects to inherit from. I’m trying to figure out how to pass the base object type to the collection class (and other methods). I’ve been able to solve this by wrapping the class in an interface but i’m wondering if there is another way to do this or if using an interface is the best way. i think my question might make more sense from the code below.

i have a base class define –

public abstract class BaseObject<TYPE,KEY>:where TYPE:BaseObject<TYPE,KEY>, new()

public KEY ObjectId {get;protected set; }

i have a class that inherits from BaseObject

public class Customer : BaseObject<Customer,Guid>

My base collection class is –

public abstract class BaseObjectCollection<T> : List<T> where T: BaseObject, new()

I also have a few methods in other class that want to reference this baseclass –

public bool ValidateRule(BaseObject dataObject) {etc...}
  • 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-27T03:46:15+00:00Added an answer on May 27, 2026 at 3:46 am

    If you use the base class in other classes that are not also generics, then I’m afraid that you’re going to have to specify the type and key parameters for the object when you pass it to methods like ValidateRule.

    In this design, an Interface implemented by the base object is probably the most appropriate solution. We use this pattern extensively in our code and it works quite well.

    One other item you could explore is reducing the complexity of the base class slightly by moving the Key into the class as an overridable (or must override) property that defaults to a string or int or whatever may be appropriate. We found that this approach (we forced all collection keys to be strings) significantly reduced the class complexity.

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

Sidebar

Related Questions

I'm trying to have an abstract base class for some builder classes so I
I have an object derived from an abstract base class and I want to
Assume some domain and view objects (that have no common base class) public class
I have a base class that I inherit from that has two zero to
I have a base class: abstract class Base and some derived classes: class Derived:
I have the following base class: abstract class Base { public abstract object Var
I have an abstract base class along the lines of: class MyAbstractClass(object): __metaclass__ =
I have an abstract base Controller class and all action controllers are derived from
I have a base class object array into which I have typecasted many different
I want to have a base class which dictates the alignment of the objects

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.