using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Generics { /* * // T는 Value 타입 class MyClass where T : struct // T는 Reference 타입 class MyClass where T : class // T는 디폴트 생성자를 가져야 함 class MyClass where T : new() // T는 MyBase의 파생클래스이어야 함 class MyClass where T : MyBase // T는 IComparable 인터페이스를 가져야 함 class MyClass where T : IComparable // 좀 더 복잡한 제약들 class EmployeeList where T : Employee, IEmployee, IComparable, new() { } // 복수 타입 파라미터 제약 class MyClass where T : class where U : struct { } * */ class TypeContraintStack where T : struct { T[] _elements; int pos = 0; public TypeContraintStack() { _elements = new T[100]; } public void Push(T element) { _elements[++pos] = element; } public T Pop() { return _elements[pos--]; } } }