Home > C#, Tips > Storing Multiple Values in Dictionary C#

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.

Advertisements
Categories: C#, Tips Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: