Collections in c#
Hello, in this blog I will talk about collections in c#. all the things written will be in my language and not in technical jargon.
There are two types (There are other types of primitive arrays too which I will not cover in this blog) of collections in c#:
- non-generic collection: ArrayList, Stack, Queue etc...
- generic collection: List<T>, Stack<T>, Queue<T> etc..
Non-Generic collection:
- It can contain data of any type. you don't have to specify a type while creating an instance of it.
- It's size is dynamic means that it can grow or shrink at runtime
- add, remove from the middle of a collection ( which we can't do in traditional c like array )
- It's not type safe since it can contain different types of objects.
Generic collections:
- It can only contain datatype given by the developer which creating an instance of it.
- It's also dynamic.
- you can add, remove etc in the collections.
- It's only contains objects with specified type, so it's type safe.
Comments
Post a Comment