I want to store values as key,value,value pair. My data is of type
Key -> int & both values -> ulong,
How to initialize & fetch values of such dictionary. I am using VS-2005.
If i use a class or struct then how do i fetch the values.
This would be an option:
Dictionary<int, KeyValuePair<ulong, ulong>> dictionary = new Dictionary<int, KeyValuePair<ulong, ulong>>();
If you want to add in a value: Key=1, Pair = {2,3}
dictionary.Add(1, new KeyValuePair<ulong, ulong>(2, 3));
If you want to retrieve those values:
var valuePair = dictionary[1];
ulong value1 = valuePair.Key;
ulong value2 = valuePair.Value;
Or simply:
ulong value1 = dictionary[1].Key;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With