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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:47:03+00:00 2026-05-11T17:47:03+00:00

I am serializing Lists of classes which are my data entities. I have a

  • 0

I am serializing Lists of classes which are my data entities. I have a DataProvider that contains a List.

I always modify items directly within the collection.

What is the best way of determining if any items in the List have changed? I am using the Compact Framework.

My only current idea is to create a hash of the List (if that’s possible) when I load the list. Then when I do a save I re-get the hash of the list and see if they’re different values. If they’re different I save and then update the stored Hash for comparison later, if they’re the same then I don’t save.

Any ideas?

  • 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-11T17:47:03+00:00Added an answer on May 11, 2026 at 5:47 pm

    If the items you add to the list implement the INotifyPropertyChanged interface, you could build your own generic list that hooks the event in that interface for all objects you add to the list, and unhooks the event when the items are removed from the list.

    There’s a BindingList<T> class in the framework you can use, or you can write your own.

    Here’s a sample add method, assuming the type has been declared with where T: INotifyPropertyChanged:

    public void Add(T item)
    {
        // null-check omitted for simplicity
        item.PropertyChanged += ItemPropertyChanged;
        _List.Add(item);
    }
    

    and the this[index] indexer property:

    public T this[Int32 index]
    {
        get { return _List[index]; }
        set {
            T oldItem = _List[index];
            _List[index] = value;
            if (oldItem != value)
            {
                if (oldItem != null)
                    oldItem.PropertyChanged -= ItemPropertyChanged;
                if (value != null)
                    value.PropertyChanged += ItemPropertyChanged;
            }
        }
    }
    

    If your items doesn’t support INotifyPropertyChanged, but they’re your classes, I would consider adding that support.

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

Sidebar

Related Questions

I'm serializing class which contains DateTime property. public DateTime? Delivered { get; set; }
Is it possible to avoid list property tags when serializing? //[Serializable()] - removed, unnecessary
I'm serializing to XML my class where one of properties has type List<string>. public
I'm de/serializing an object like so: public class myClass : ISerializable { public List<OType>
When serializing/de-serializing certain classes I've come across the need to flag or mark certain
A project I'm working on requires serializing a data structure before shutting down and
When serializing, I would like to serialize an object only once, then any references
I'm serializing an object in a C# VS2003 / .Net 1.1 application. I need
I am serializing a class using simple-xml ( http://simple.sourceforge.net/ ) but when i try
Has anyone run into issues serializing components into a file and reading them back,

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.