2 using System
.Collections
.Generic
;
3 using System
.Reflection
;
5 namespace GenericSharingTest
{
11 public class GenA
<T
> {
12 public int genericMethod
<M
> () {
16 public int genericMethodCaller () {
17 return genericMethod
<int> ();
22 static bool haveError
= false;
24 public static void error (string message
) {
26 Console
.WriteLine (message
);
29 public static void typeCheck (String method
, Object obj
, Type t
) {
30 if (obj
.GetType () != t
)
31 error ("object from " + method
+ " should have type " + t
.ToString () + " but has type " + obj
.GetType ().ToString ());
34 public static int Main ()
36 GenA
<ClassA
> ga
= new GenA
<ClassA
> ();
37 GenA
<GenA
<ClassB
>> gaab
= new GenA
<GenA
<ClassB
>> ();
39 if (ga
.genericMethodCaller () != 123)
40 error ("ga.genericMethodCaller");
42 if (gaab
.genericMethodCaller () != 123)
43 error ("gaab.genericMethodCaller");