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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:51:02+00:00 2026-05-12T14:51:02+00:00

I have a specialized class, BusinessObjectList, with this declaration: public class BusinessObjectList<T> : List<BusinessObject>

  • 0

I have a specialized class, BusinessObjectList, with this declaration:

public class BusinessObjectList<T> : List<BusinessObject> where T: BusinessObject {}

And I want to serialize objects of this class, like:

info.AddValue("myList", myList);

I tried to add the interface ISerializable, but with no success.

public class BusinessObjectList<T> : List<BusinessObject>, ISerializable where T: BusinessObject {}

The list is always null when unserialized.
I think List<> objects are serializable, but what about subclasses of them?

EDIT:

Just for future reference, here is the entire class:

BusinessObjectList.cs (When you call save(), it automatically persists on DB all inserts and removes from the list, and also saves all modified values on the business objects):

[Serializable()]
public class BusinessObjectList<T> : List<BusinessObject>,ISerializable where T: BusinessObject
{
    public delegate void BusinessObjectListDeleteHandler(T objDeleted);
    public event BusinessObjectListDeleteHandler deleteHandler;

    List<BusinessObject> objsForDelete = new List<BusinessObject>();
    public BusinessObjectList()
    {

    }

    public new void Add(BusinessObject item)
    {
        base.Add(item);
    }
    public new T this[int index]
    {
        get
        {                 
            return (T)base[index];
        }
    }

    public bool save()
    {
        foreach (T obj in objsForDelete)
        {
            if (deleteHandler != null)
                deleteHandler(obj);
            obj.delete();
        }
        objsForDelete.Clear();
        foreach (BusinessObject obj in this)
        {
            obj.save();
        }
        return true;
    }

    public new void Clear()
    {
        foreach (BusinessObject obj in this)
        {
            //obj.delete();
            objsForDelete.Add(obj);
        }
        base.Clear();
    }

    public new void Remove(BusinessObject obj)
    {
        // obj.delete();
        objsForDelete.Add(obj);
        base.Remove(obj);
    }

    public new void RemoveAt(int index)
    {
        objsForDelete.Add(this[index]);
        base.RemoveAt(index);
    }


    #region ISerializable Members

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        // should I do something here??
    }

    #endregion
}

And BusinessObject.cs:

[Serializable()]
public abstract class BusinessObject:ISerializable
{
    public abstract bool save();
    public abstract bool delete();
    public abstract DbTransaction startTransaction();
    public abstract void useTransaction(DbTransaction transaction);
    public abstract DbTransaction getTransaction();

    #region ISerializable Members

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {            
        // nothing to serialize here            
    }

    #endregion
}
  • 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-12T14:51:02+00:00Added an answer on May 12, 2026 at 2:51 pm

    First of all, you should inherit from System.Collections.ObjectModel.Collection<T>, not List<BusinessObject>. It’s better to inherit from Collection<T> so that you can have control over all changes to the list (even changes made through IList<T>) by overriding InsertItem, SetItem, etc. It’s probably also better to inherit from a collection of T than a collection of BusinessObject so that the methods and indexer you inherit from your base class use the correct type.

    To answer your question, none of the .Net collection types (including Collection<T>) are serializable. You’ll need to serialize and deserialize the collection yourself; see here for instructions.

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

Sidebar

Ask A Question

Stats

  • Questions 286k
  • Answers 286k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I understand your question correctly, simply calling SetSection with… May 13, 2026 at 4:50 pm
  • Editorial Team
    Editorial Team added an answer The method you want to call is CGContextClipToMask. Just draw… May 13, 2026 at 4:50 pm
  • Editorial Team
    Editorial Team added an answer Use negative lookaheads to disallow what you don't want: ^(?![a-zA-Z]+$)(?![0-9]+$)[a-zA-Z… May 13, 2026 at 4:50 pm

Related Questions

I often design system where I have a class in my system that has
I have a question with fluent interfaces. We have some objects that are used
I am developing in python a file class that can read and write a
I have a specialized list that holds items of type IThing : public class

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.