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

test-398.cs « tests « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d8cc6f02d20be111260e1c4be6b4ca0be0b2f20a (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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//
// Test for access modifiers
//

using System;

 public class Tester {

	 public static void Main ()
	 {
		 A a = new A (8);
		 B b = new B (9);

		 b.SetCount (10);
		 Console.WriteLine ("b.Count should be 9: {0}", b.Count);
		 Console.WriteLine ("b [{0}] should return {0}: {1}", 10, b [10]);

		 Console.WriteLine ("a.Message : {0}", a.Message);
		 b.Message = "";
		 Console.WriteLine ("b.Messasge : {0}", b.Message);
	 }

 }

 public class A {

	 protected int count;

	 public A (int count)
	 {
		 this.count = count;
	 }

	 public virtual int Count {
		 get {
			 return count;
		 }
		 protected set {
			 count = value;
		 }
	 }

	 public virtual int this [int index] {
		 get {
			 return index;
		 }
	 }

	 public virtual string Message {
		 get {
			 return "Hello Mono";
		 }
	 }

 }

 public class B : A {

	 public B (int count) : base (count)
	 {
	 }

	 public override int Count {
		 protected set {
		 }
	 }

	 public void SetCount (int value)
	 {
		 Count = value;
	 }

	 public override int this [int index] {
		 get {
			 return base [index];
		 }
	 }

	 public new string Message {
		 get {
			 return "Hello Mono (2)";
		 }
		 internal set {
		 }
	 }

 }