1 using System; 2 using director_stringNamespace; 3 4 public class runme 5 { Main()6 static void Main() 7 { 8 runme r = new runme(); 9 r.run(); 10 } 11 run()12 void run() 13 { 14 String s; 15 16 director_string_A c = new director_string_A("hi"); 17 for (int i=0; i<3; i++) { 18 s = c.call_get(i); 19 Object ii = i; 20 if (s != ii.ToString()) throw new Exception("director_string_A.get(" + i + ") failed. Got:" + s); 21 } 22 23 director_string_B b = new director_string_B("hello"); 24 25 s = b.call_get_first(); 26 if (s != "director_string_B.get_first") throw new Exception("call_get_first() failed"); 27 28 s = b.call_get(0); 29 if (s != "director_string_B.get: hello") throw new Exception("get(0) failed"); 30 } 31 } 32 33 class director_string_B : A { director_string_B(String first)34 public director_string_B(String first) : base(first) { 35 } get_first()36 public override String get_first() { 37 return "director_string_B.get_first"; 38 } 39 get(int n)40 public override String get(int n) { 41 return "director_string_B.get: " + base.get(n); 42 } 43 } 44 45 class director_string_A : A { director_string_A(String first)46 public director_string_A(String first) : base(first) { 47 } get(int n)48 public override String get(int n) { 49 Object nn = n; 50 return nn.ToString(); 51 } 52 } 53 54