Solved

Difference between observablecollection and inotifypropertychanged and  INotifyCollectionChanged

Posted on 2010-11-11
3
1,212 Views
Last Modified: 2013-12-17
Hi Friends,

Can you please help me in understanding

Difference between observablecollection and inotifypropertychanged and
'  INotifyCollectionChanged

Thankyou
0
Comment
Question by:N_Sri
3 Comments
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 250 total points
Comment Utility
INotify... are both interfaces.  Classes that implement these interfaces must implement methods, properties and events that are described in the interface.  This allows code to be guaranteed of methods that an object supports.  For example, all objects that implement IDisposable are known to have a method named "Dispose" (because Dispose is defined in the interface).  That allows me to write a method that takes an IDisposable parameter, and I don't need to know or care if the object passed to my method is a Stream, database connection, etc - all I know is that this object implements IDisposable, therefore I know I can call .Dispose()
void someMethod(IDisposable someObject)
{
    someObject.Dispose();
}
ObservableCollection is a class that implements the two interfaces - it uses events to notify you when the contents of the collection it represents have changed.
http://msdn.microsoft.com/en-us/library/ms668604.aspx
http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx
http://msdn.microsoft.com/en-us/library/system.collections.specialized.inotifycollectionchanged.aspx
0
 
LVL 16

Assisted Solution

by:ToddBeaulieu
ToddBeaulieu earned 250 total points
Comment Utility
Additionally,

Many of the UI controls are designed to be bound to a datasource that lets it know when rows are added, changed or removed. This is done via the INotifyCollectionChanged  interface. I suspect the inotifypropertychanged  interface in this case is used to signal changes to the collection property itself (like the Count property).

In your code you'll probably end up just using OCs, but framework and reusable code typically calls for a INotifyCollectionChanged  data source, because many data sources can implement this interface ... not just the OC. In fact, you could easily write your own class that implements this interface and can be bound to a UI control.
0
 

Author Closing Comment

by:N_Sri
Comment Utility
thankyou
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now