Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: ee0bc0d176
Fetching contributors…

Cannot retrieve contributors at this time

52 lines (39 sloc) 1.038 kB
using System;
using System.Collections.Generic;
using System.Reflection;
namespace GenericSharingTest {
public class ClassA {}
public class ClassB {}
public class ClassC {}
public class GenA<T> {
public int genericMethod<M> () {
return 123;
}
public int genericMethodCaller () {
return genericMethod<int> ();
}
}
public class main {
static bool haveError = false;
public static void error (string message) {
haveError = true;
Console.WriteLine (message);
}
public static void typeCheck (String method, Object obj, Type t) {
if (obj.GetType () != t)
error ("object from " + method + " should have type " + t.ToString () + " but has type " + obj.GetType ().ToString ());
}
public static int Main ()
{
GenA<ClassA> ga = new GenA<ClassA> ();
GenA<GenA<ClassB>> gaab = new GenA<GenA<ClassB>> ();
if (ga.genericMethodCaller () != 123)
error ("ga.genericMethodCaller");
if (gaab.genericMethodCaller () != 123)
error ("gaab.genericMethodCaller");
if (haveError)
return 1;
return 0;
}
}
}
Jump to Line
Something went wrong with that request. Please try again.