The .net Framework Provides Specialized Classes for data storage and retrieval .System.collection and system.collections.generic .
A generic collection is strongly typed (type safe), meaning that you can only put one type of object into it.
Strongly Types VS Weekly Typed :
Strongly Typed :
When we say something is strongly typed we mean that the type of the object is known and available.
A) This eliminates type mismatches at runtime.
B)Another benefit of type safety is that performance is better with value type objects because they don't incur overhead of being converted to and from type object
A generic collection is strongly typed (type safe), meaning that you can only put one type of object into it.
Ex:
Collection<int> a =new collection<int>() ;
a.Add(1);
a.Add(2);
a.Add("gg") //// Compilation Error .
So it is an strongly Typed .
Weakly Typed :
Type of object is unknown and not available .
ArrayList list = new ArrayList();
list.Add(10);
list.Add("Hello");
list.Add(DateTime.Now);
works because ArrayList is weakly typed because it doesn't really care about the underlying element types .works because ArrayList is weakly typed because it doesn't really care about the underlying element types
NON GENERIC COLLECTIONS :
1.ArrayList :
2.
MAIN GENERIC COLLECTIONS :
1.DICTIONARY :
2.LIST
:
A generic collection is strongly typed (type safe), meaning that you can only put one type of object into it.
Strongly Types VS Weekly Typed :
Strongly Typed :
When we say something is strongly typed we mean that the type of the object is known and available.
A) This eliminates type mismatches at runtime.
B)Another benefit of type safety is that performance is better with value type objects because they don't incur overhead of being converted to and from type object
A generic collection is strongly typed (type safe), meaning that you can only put one type of object into it.
Ex:
Collection<int> a =new collection<int>() ;
a.Add(1);
a.Add(2);
a.Add("gg") //// Compilation Error .
So it is an strongly Typed .
Weakly Typed :
Type of object is unknown and not available .
ArrayList list = new ArrayList();
list.Add(10);
list.Add("Hello");
list.Add(DateTime.Now);
works because ArrayList is weakly typed because it doesn't really care about the underlying element types .works because ArrayList is weakly typed because it doesn't really care about the underlying element types
NON GENERIC COLLECTIONS :
1.ArrayList :
2.
MAIN GENERIC COLLECTIONS :
1.DICTIONARY :
2.LIST
:
Comments
Post a Comment