using System; namespace Tests { class Generics { class ClassA : IDisposable { public void Dispose() { } } static void DoDispose(mut T val) where T : IDisposable { val.Dispose(); } struct Disposer { static void UseDispose(IDisposable disp) { } static void DoDisposeA(mut T val) where T : IDisposable { val.Dispose(); UseDispose(val); } static void DoDisposeB(mut T val) where T : IDisposable { val.Dispose(); } } [Test] public static void TestGenericDelegates() { delegate void(String v) dlg = scope => StrMethod; CallGenericDelegate(dlg); CallGenericDelegate(scope => StrMethod); } public static void CallGenericDelegate(delegate void(T v) dlg) { } public static void StrMethod(String v) { } [Test] public static void TestBasics() { } } class ConstGenerics { public static float GetSum(float[TCount] vals) where TCount : const int { float total = 0; for (int i < vals.Count) total += vals[i]; return total; } [Test] public static void TestBasics() { float[5] fVals = .(10, 20, 30, 40, 50); float totals = GetSum(fVals); Test.Assert(totals == 10+20+30+40+50); } } }