summaryrefslogtreecommitdiff
path: root/tests/src/JIT/opt/Inline/interfaceProperty.cs
blob: f90e5619f26244c8e7b6a8136294b7f66445630f (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

// Interface Properties
using System;
namespace JitInliningTest
{
    interface IEmployee
    {
        string Name
        {
            get;
            set;
        }

        int Counter
        {
            get;
        }
    }

    public class Employee : IEmployee
    {
        public static int numberOfEmployees;
        private int counter;
        private string name;
        // Read-write instance property:
        public string Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
            }
        }
        // Read-only instance property:
        public int Counter
        {
            get
            {
                return counter;
            }
        }
        // Constructor:
        public Employee()
        {
            counter = ++counter + numberOfEmployees;
        }
    }

    public class interfaceProperty
    {
        public static int Main()
        {
            Employee.numberOfEmployees = 1;
            Employee e1 = new Employee();
            e1.Name = "100";

            if (e1.Counter == 2)
                return Convert.ToInt32(e1.Name);
            else
                return 1;
        }
    }

}