Overloading a method that takes a generic list with different types as a parameter
问题 How can I overload a method that takes a Generic List with different types as a parameter? For example: I have a two methods like so: private static List<allocations> GetAllocationList(List<PAllocation> allocations) { ... } private static List<allocations> GetAllocationList(List<NPAllocation> allocations) { ... } Is there a way I can combine these 2 methods into one? 回答1: Sure can... using generics! private static List<allocations> GetAllocationList<T>(List<T> allocations) where T :