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?
Sure can… using generics!
This assumes that your “allocations”, “PAllocation” and “NPAllocation” all share some base class called “BasePAllocationClass”. Otherwise you can remove the “where” constraint and do the type checking yourself.