Merge pull request #5675 from mono/glib-debug-symbols
[mono.git] / mcs / tests / test-dictinit-02.cs
1 using System;
2 using System.Collections.Generic;
3
4 class Program
5 {
6         static int Main ()
7         {
8                 var c = new C {
9                         ["l1"] = new C {
10                                 ["l2"] = new C () {
11                                         Value = 10
12                                 }
13                         },
14                         ["l5"] = {
15                                 ["51"] = new C () {
16                                         Value = 100
17                                 }
18                         }
19                 };
20
21                 if (c ["l1"]["l2"].Value != 10)
22                         return 1;
23
24                 if (c ["l5"]["51"].Value != 100)
25                         return 2;
26
27                 return 0;
28         }
29 }
30
31
32 class C
33 {
34         public Dictionary<string, C> Dict = new Dictionary<string, C> ();
35
36         public int Value;
37
38         public C this [string arg] {
39                 get {
40                         C c;
41                         if (!Dict.TryGetValue (arg, out c)) {
42                                 c = new C ();
43                                 Dict [arg] = c;
44                         }
45
46                         return c;
47                 }
48                 set {
49                         Dict [arg] = value;
50                 }
51         }
52 }