You've already forked linux-packaging-mono
Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
52
mcs/tests/test-dictinit-02.cs
Normal file
52
mcs/tests/test-dictinit-02.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
class Program
|
||||
{
|
||||
static int Main ()
|
||||
{
|
||||
var c = new C {
|
||||
["l1"] = new C {
|
||||
["l2"] = new C () {
|
||||
Value = 10
|
||||
}
|
||||
},
|
||||
["l5"] = {
|
||||
["51"] = new C () {
|
||||
Value = 100
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (c ["l1"]["l2"].Value != 10)
|
||||
return 1;
|
||||
|
||||
if (c ["l5"]["51"].Value != 100)
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class C
|
||||
{
|
||||
public Dictionary<string, C> Dict = new Dictionary<string, C> ();
|
||||
|
||||
public int Value;
|
||||
|
||||
public C this [string arg] {
|
||||
get {
|
||||
C c;
|
||||
if (!Dict.TryGetValue (arg, out c)) {
|
||||
c = new C ();
|
||||
Dict [arg] = c;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
set {
|
||||
Dict [arg] = value;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user