-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06_DictionaryInitializer.cs
60 lines (48 loc) · 1.06 KB
/
06_DictionaryInitializer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
//
// All exmaples are taken from MS Roslyn Codeplex page
// https://www.codeplex.com/Download?ProjectName=roslyn&DownloadId=824694
//
namespace CSharp6Samples_DictionaryInitializer
{
#region CSharp 5
public class DictionaryInitializerV5
{
private void Method ()
{
var numbers = new Dictionary<int, string>
{
{ 7, "seven" },
{ 13, "thirteen" },
{ 9, "nine" }
};
var names = new Dictionary<string, string>
{
{"me", "Luke"},
{"you", "Leia"},
{"father", "Lord Vader"}
};
}
}
#endregion
#region CSharp 6
public class DictionaryInitializerV6
{
private void Method() {
var numbers = new Dictionary<int, string>
{
[7] = "seven",
[9] = "nine",
[13] = "thirteen"
};
var names = new Dictionary<string, string>
{
["me"] = "Luke",
["you"] = "Leia",
["father"] = "Lord Vader"
};
}
}
#endregion
}