Jump to content
xisto Community
Sign in to follow this  
tinoymalayil

Advantage Of Using Generic Collection In C#

Recommended Posts

Please tell me what is the advantage of using generic collection in c#.We can use the normal collection class like List myList =new List().and the generic collection List<string> myList=new List<String>(). Could you please reply how the working of the generic ollection class?

Share this post


Link to post
Share on other sites

I have used collection framework in Java.Where it works exactly the way you have mentioned here.What I understand about collection is- it is a way to put objects/wrapper classes intodifferent data structures like array,arraylists, vectors, Maps e.t.c.List myList =new List().- > is a list where one can add objects of data type Integer,Float,Double, String or anything else.But List<string> myList=new List<String>() is a generic one wherein one can add an object of only String type.But it has to be kept in mind that this type information is maintained onlyduring compilation and not on runtime.During runtime a type erasure works that deletes the type information during runtime.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.