System.Collection!!!!!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What is the dif between System.Collections.ICollection and
System.Collections.Generic.ICollection ?
When would I use one and another?
 
The System.Collections.Generic.ICollection<T> interface is the base interface
for classes in the System.Collections.Generic namespace.

The System.Collections.ICollection interface is the base interface for
classes in the System.Collections namespace.

You have an instance of the former when you have an instance of a
Generic.Collection

using System.Collections.Generic;
ICollection<int> _GenericCollection = new LinkedList<int>();

You have an instance of the latter when you have an instance of a
Collections.Collection

using System.Collections;
ICollection _RegularCollection = new Hashtable();

You should read the MSDN help to find out more, there are lots of examples.
 
Donet framework exposes two types of collection. One is generic collection
and other one is nongeneric collection. Generic Collection is based on the
concept Generic and thus are more optimized than non-generic collection. In
generic collection, you could avoid Boxing/Unboxing overhead.

All collectionsin System.Collections.Generic inherits from
System.Collections.Generic.ICollection.
The other collection classes inherits from System.Collections.ICollection.

If you are implementing a generic collection, then you should inherit from
System.Collections.Generic.ICollection else from
System.Collections.ICollection.

Regards
Tariq Karim
 
Back
Top