I have a data like in (string , int) pair. How to store this data in collection object. Both values can be duplicate. Which collection object should i use??
EDIT: How can i access elements separately..??
I have a data like in (string , int) pair. How to store this data in collection object. Both values can be duplicate. Which collection object should i use??
EDIT: How can i access elements separately..??
You can use List<KeyValuePair<string,int>>
.
This will store a list of KeyValuePair
's that can be duplicate.
You can use List<KeyValuePair<string, int>>
if you want to add & remove items, or KeyValuePair<string, int>[]
if the number of items is known
If you want to avoid repeating the key for multiple values you can use Dictionary<string, List<int>>
.