You've already forked linux-packaging-mono
Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
49
mcs/tests/test-dictinit-01.cs
Normal file
49
mcs/tests/test-dictinit-01.cs
Normal file
@ -0,0 +1,49 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user