28
1
using System;
2
using System.Collections.Generic;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
9
Dictionary<string, int> dictionary =new Dictionary<string, int>();
10
11
//add items in dictionary
12
dictionary.Add("linux", 1);
13
dictionary.Add("windows", 2);
14
dictionary.Add("mac", 3);
15
16
//Get value using Key
17
int result;
18
19
if(dictionary.TryGetValue("windows", out result))
20
{
21
Console.WriteLine(result);
22
}
23
else
24
{
25
Console.WriteLine("Could not find the specified key.");
26
}
27
}
28
}
Cached Result