Quantcast
Channel: DevtheWeb.NET » .NET
Viewing all articles
Browse latest Browse all 7

How to declare and init a static Dictionary

$
0
0

You may want to declare a static Dictionary variable in you code, here’s a simple example how it can be done in C#:

using System.Collections.Generic;

public static Dictionary<string, string> dict = new Dictionary<string, string>() {
{“key 1″, “value 1″},
{“key 2″, “value 2″},
{“key 3″, “value 3″}
};

That’s all. It’s similar to the array declaration :)


Viewing all articles
Browse latest Browse all 7

Trending Articles