Storing Multiple Values in Dictionary C#
We All know the famous Dictionary
Dictionary<string,string> myDictionary
Its normally used for storing Key, Value pair.
Sometimes we want to store something like Key,Value,value.
for eg.
Dictionary<string,string,string> myDictionary
Unfortunately we don’t such structure in .Net, but there is workaround for such situation.
Create a Class or Struct and use it as Value.
for eg.
public class MyClass
{
public string Value1 { get; set; }
public string Value2 { get; set; }
}
Dictionary<string, MyClass> myDictionary
Hope this helps.
Categories: C#, Tips
.Net, C#, Dictionary
Comments (0)
Trackbacks (0)
Leave a comment
Trackback