using System; using System.IO; using System.Collections.Generic; namespace generics { public delegate T GenericDelegate(ref T t); public class A { } public class A { public delegate U GenericDelegateInGenericClass(T t, U u); public T bar(X x, T t) where X : new() { A a; return t; } } public class B where T : class { internal A at; string name; public void foo() { } public void fooParams(params T[] ts) { } public static void staticFoo() { } public string Name { get { return name; } set { name = value; } } public event GenericDelegate myEvent; public static B operator ++(B a) { return new B(); } ~B() { } void f() where X : class { new B(); } } public class Outer { public class Inner where U1 : T1 { public T1 t; public Func myFunc; public void MyMethod(W1 a, W2 b, U2 c, T2 d) => throw null; } } public class Grid where T : struct { const int NumRows = 26; const int NumCols = 10; T[,] cells = new T[NumRows, NumCols]; public int this[int i] { get { return i; } } public T this[char c, int col] { get { c = Char.ToUpper(c); if (c < 'A' || c > 'Z') { throw new ArgumentException(); } if (col < 0 || col >= NumCols) { throw new IndexOutOfRangeException(); } return cells[c - 'A', col]; } set { c = Char.ToUpper(c); if (c < 'A' || c > 'Z') { throw new ArgumentException(); } if (col < 0 || col >= NumCols) { throw new IndexOutOfRangeException(); } cells[c - 'A', col] = value; } } } class Test { void Main() { B bs = new B(); bs.at = new A(); bs.foo(); bs.fooParams("a", "b"); B.staticFoo(); bs.Name = ""; bs.myEvent += new GenericDelegate(f); bs++; Grid g = new Grid(); int j = g['e', 1]; new Outer.Inner().t = 3; new Outer.Inner().MyMethod(1.0, 2, "3", true); new A().bar(2, ""); new A().bar(new Test(), 2); } string f(ref string s) { return s; } } class Subtle { public void fs(int i) { } public void fs(int i, int j) { } public void fs(int i) { } } class Param { enum E { x }; } class ConstructedMethods { void CM1() { } T CM2(T t) { return t; } class Class { public T2 CM3(T2 t, T1 t1) { return t; } } void NonCM() { } void CM() { CM1(); CM1(); CM2(4); CM2(2.0); new Class().CM3(1.0, 2); new Class().CM3(1.0, 2.0); } } interface Interface { void set(T t); } class Inheritance : Interface { public void set(T t) { } } class InheritanceTest { Inheritance member; } interface Interface2 { T2 M(T1 x); } }