2010-02-19 Rodrigo Kumpera <rkumpera@novell.com>
[mcs.git] / tests / gtest-039.cs
blob24d3d62f668be3c572a7e32680f7f32232d1b3b1
1 //
2 // Important test for the runtime: check whether we're correctly
3 // creating the vtable for nested types.
4 //
6 using System;
8 interface IMonkey<T>
10 T Jump ();
13 class Zoo<T>
15 T t;
17 public Zoo (T t)
19 this.t = t;
22 public T Name {
23 get { return t; }
26 public IMonkey<U> GetTheMonkey<U> (U u)
28 return new Monkey<T,U> (this, u);
31 public class Monkey<V,W> : IMonkey<W>
33 public readonly Zoo<V> Zoo;
34 public readonly W Data;
36 public Monkey (Zoo<V> zoo, W data)
38 this.Zoo = zoo;
39 this.Data = data;
42 public W Jump ()
44 Console.WriteLine ("Monkey {0} from {1} jumping!", Data, Zoo.Name);
45 return Data;
50 class X
52 static void Main ()
54 Zoo<string> zoo = new Zoo<string> ("Boston");
55 IMonkey<float> monkey = zoo.GetTheMonkey<float> (3.14F);
56 monkey.Jump ();