Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test-543.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 606b89ad3f1f2304080c8a8d845a9e93185a8826 (plain)
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
// Compiler options: -r:test-543-lib.dll

using System;

class BetterMethod
{
    public int this[params bool[] args] { get { return 2; } }
    public string this[bool a, object b] { get { throw new NotImplementedException (); } }
}

class MainClass
{
    public int this [int expectedLength, params string[] items]
    {
        get { return 4; }
        set {
            if (expectedLength != items.Length)
                throw new ArgumentException (expectedLength + " != " + items.Length);
        }
    }

    public object this [int expectedLength, params object[] items]
    {
        get { return null; }
        set {
            if (expectedLength != items.Length)
                throw new ArgumentException (expectedLength + " != " + items.Length);
        }
    }
    
    public bool this [int expectedLength, bool isNull, params object[] items]
    {
        get { return false; }
        set {
            if (expectedLength != items.Length)
                throw new ArgumentException (expectedLength + " != " + items.Length);
        }
    }

    static void Main(string[] args)
    {
        MainClass t = new MainClass();
        t [2, "foo", "doo"] = 2;
        t [3, new object[3]] = null;
        t [2, new int[] { 1 }, new string[] { "c", "b", "a" }] = null;
        t [0, true] = t [0, true];
        t [1, false, "foo"] = t [0, false, "foo", "doo"];
        
        ExternClass e = new ExternClass ();
        e ["a", "b", "b"] = false;
        
        BetterMethod bm = new BetterMethod ();
        Console.WriteLine (bm[true, false]);
    }
}