/Test/Resources/cs/Generics.cs
C# | 121 lines | 91 code | 30 blank | 0 comment | 0 complexity | e383feadf356609aace4f2f0dc7d849d MD5 | raw file
1using System; 2using System.Collections.Generic; 3 4class Foo<TBar, TBaz> {} 5 6abstract class Bar<T> { 7 8 T bang; 9 10 public abstract Bar<T> Self (); 11 12 public abstract Bar<string> SelfString (); 13} 14 15abstract class Baz { 16 17 public abstract TBang Gazonk<TBang> (object o); 18 19 public abstract Bar<TBingo> Gazoo<TBingo> (); 20} 21 22class Zap {} 23interface IZoom {} 24 25class Bongo<T> where T : Zap, IZoom { 26 27 enum Dang { 28 Ding = 2, 29 Dong = 12, 30 } 31} 32 33class Parent<T> {} 34class Child<T> : Parent<T> { 35 public T [] array; 36} 37class TamChild : Child<Tamtam> {} 38class RecChild : Child<RecChild> {} 39 40class Tamtam { 41 42 static void Foo<TFoo> (TFoo tf) 43 { 44 } 45 46 static void Bar () 47 { 48 Foo (2); 49 } 50 51 static List<TBeta> Beta<TBeta> () 52 { 53 return new List<TBeta> (); 54 } 55 56 static List<TCharlie> Charlie<TCharlie> () 57 { 58 return new List<TCharlie> (); 59 } 60} 61 62class It { 63 64 public IEnumerable<Foo<string, string>> Pwow () 65 { 66 yield return new Foo<string, string> (); 67 yield return new Foo<string, string> (); 68 yield return new Foo<string, string> (); 69 } 70 71 public void ReadPwow () 72 { 73 foreach (Foo<string, string> foo in Pwow ()) 74 Tac (foo); 75 } 76 77 public void Tac<T> (T t) 78 { 79 } 80} 81 82class Duel<T1, T2, T3> where T2 : T1 where T3 : T2 {} 83 84class ChildReader { 85 86 public int Read (TamChild t) 87 { 88 return t.array.Length; 89 } 90} 91 92struct Nilible<T> where T : struct { 93 public T t; 94} 95 96class Null { 97 98 public static int Compare<T> (Nilible<T> x, Nilible<T> y) where T : struct 99 { 100 return Comparer<T>.Default.Compare (x.t, y.t); 101 } 102} 103 104public class DoubleFuncClass { 105 public void Test () { Test<int> (); Test<int, int> (); } 106 public void Test<T> () { Test<T, int> (); Test<T, T> (); } 107 public void Test<T, T1> () { Test<T1> (); Test<T1, T> (); } 108} 109 110public class DoubleFuncClass<X> { 111 public void Test () { Test<int> (); Test<int, int> (); } 112 public void Test<T> () { Test<X, int> (); Test<T, X> (); } 113 public void Test<T, T1> () { Test<T1> (); Test<T1, T> (); } 114} 115 116public class LaMatrix { 117 public static T At<T> (T[,] m, int i, int j) 118 { 119 return m [i, j]; 120 } 121}