Coggle requires JavaScript to display documents.
public class GenericList<T> { public void Add(T number) { throw new NotImplementedException(); } public T this[int index] { get { throw new NotImplementedException(); } } }
var books = new GenericList<Book>(); books.Add(book);
var numbers = new GenericList<int>(); numbers.Add(1);
var dict = new GenericDictionary<string, Book>();
dict.Add("Hello", book);
public class GenericDictionary<TKey, TValue> { public void Add(TKey key, TValue value) { } }
public class Utilities { public int Max(int a, int b) { return a > b ? a : b; } // Generic Method public T Max<T>(T a, T b) { return a > b ? a : b; } }
public class Utilities { public int Max(int a, int b) { return a > b ? a : b; } // Generic Method public T Max<T>(T a, T b) where T : IComparable { return a.CompareTo(b) > 0 ? a : b; } }
public class Utilities<T> where T : IComparable { public int Max(int a, int b) { return a > b ? a : b; } // Generic Method public T Max(T a, T b) { return a.CompareTo(b) > 0 ? a : b; } }
public class Utilities<T> where T : IComparable, new() { public void DoSomething(T value) { var obje = new T(); } }
public class DiscountCalculator<TProduct> where TProduct : Product { public int CalculateDiscount(TProduct product) { return product.Price; } }