C#/.NET interview Question – Types of collections in .NET
Collection: - Collections are basically group of records which can be treated as a one logical unit..NET Collections are divided in to four important categories as follows.
Let’s begin with Indexed based and key value pair.
Indexed based: - It helps you to access the value of row by using the internal generated index number by the collection.
Key Value Pair: - It helps you to access value by the user defined key.
Below is the example of country collection for Indexed based and key value pair.
When you want to access India through Index based you have to write like below code.
Specialized Collection: -It is very specific collections which are meant for very specific purpose like hybrid dictionary that start
as list and become hashtable.
Collection: - Collections are basically group of records which can be treated as a one logical unit..NET Collections are divided in to four important categories as follows.
- Indexed based.
- Key Value Pair.
- Prioritized Collection.
- Specialized Collection.
Let’s begin with Indexed based and key value pair.
Indexed based: - It helps you to access the value of row by using the internal generated index number by the collection.
Key Value Pair: - It helps you to access value by the user defined key.
Below is the example of country collection for Indexed based and key value pair.
When you want to access India through Index based you have to write like below code.
MessageBox.Show(myarray[0]); //for array MessageBox.Show(mylist[0]); //for listNow, when we want to access the same output “India” by Key value pair.
MessageBox.Show(myhash["IND"].ToString()); //for hashtablePrioritized Collection: -It helps us to get the element in a particular sequence.
Specialized Collection: -It is very specific collections which are meant for very specific purpose like hybrid dictionary that start
as list and become hashtable.
0 comments:
Post a Comment