linux-packaging-mono/mcs/tests/test-dictinit-01.cs
Jo Shields 8b9b85e7f5 Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
2014-10-04 11:27:48 +01:00

49 lines
589 B
C#

using System;
using System.Collections.Generic;
class Program
{
static int Main ()
{
var c1 = new C {
["aaa"] = 12,
};
if (c1.Dict ["aaa"] != 12)
return 1;
var c2 = new C {
["a1"] = 5,
["a2"] = 10,
Value = 20,
};
if (c2.Dict ["a1"] != 5)
return 2;
if (c2.Dict ["a2"] != 10)
return 3;
if (c2.Value != 20)
return 4;
return 0;
}
}
class C
{
public Dictionary<string, int> Dict = new Dictionary<string, int> ();
public int Value;
public int this [string arg] {
get {
return Dict [arg];
}
set {
Dict [arg] = value;
}
}
}