Question :
Best implementation for Key Value Pair Data Structure?,
Answer :
So I’ve been poking around with C# a bit lately, and all the Generic Collections have me a little confused. Say I wanted to represent a data structure where the head of a tree was a key value pair, and then there is one optional list of key value pairs below that (but no more levels than these). Would this be suitable?
public class TokenTree { public TokenTree() { /* I must admit to not fully understanding this, * I got it from msdn. As far as I can tell, IDictionary is an * interface, and Dictionary is the default implementation of * that interface, right? */ SubPairs = new Dictionary(); } public string Key; public string Value; public IDictionary SubPairs; }
It’s only really a simple shunt for passing around data.
,
There is an actual Data Type called KeyValuePair, use like this
KeyValuePair myKeyValuePair = new KeyValuePair("defaultkey", "defaultvalue");
That’s the answer Best implementation for Key Value Pair Data Structure?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.
Disclaimer :
The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you