class MyStack { T[] _elements; int pos = 0; public MyStack() { _elements = new T[100]; } public void Push(T element) { _elements[++pos] = element; } public T Pop() { return _elements[pos--]; } } internal class Program { private static void Main(string[] args) { // 두 개의 서로 다른 타입을 갖는 스택 객체를 생성 MyStack numberStack = new MyStack(); MyStack nameStack = new MyStack(); } } // T는 Value 타입 class MyClassS where T : struct { } // T는 Reference 타입 class MyClassC where T : class { } // T는 디폴트 생성자를 가져야 함 class MyClassD where T : new() { } // T는 EventArgs의 파생클래스이어야 함 class MyClassMyBase where T : EventArgs { } // T는 IComparable 인터페이스를 가져야 함 class MyClass where T : IComparable { } // 좀 더 복잡한 제약들 class EmployeeList where T : EventArgs, IDisposable, IComparable, new() { } // 복수 타입 파라미터 제약 class MyClass where T : class where U : struct { }