다른 형식의 일반 목록을 매개 변수로 사용하는 메서드를 오버로드하려면 어떻게해야합니까? 예를 들어다른 형식의 일반 목록을 매개 변수로 사용하는 메서드 오버로드
:
private static List<allocations> GetAllocationList(List<PAllocation> allocations)
{
...
}
private static List<allocations> GetAllocationList(List<NPAllocation> allocations)
{
...
}
내가 하나에이 두 방법을 결합 할 수있는 방법이 있나요 :
그래서 같은 두 가지 방법이 있나요?
,하지만 난 유형 검사를하는 것에 대해 어떻게 가야합니까? 또한 allocations 매개 변수를 반복해야합니다. allocations.ForEach (대리자 (PAllocation PA) {...});를 사용하려고했습니다. 호환되지 않는 익명의 함수 서명이라는 오류가 나타납니다. 어떤 아이디어? – Jon
당신은 할 수 없어 (foreach var 할당)? – womp