2010-03-02 5 views

답변

4
public class VPair<TFirst, TSecond> 
    { 
     public TFirst First { get; set; } 
     public TSecond Second { get; set; } 

     public VPair(TFirst first, TSecond second) 
     { 
      First = first; 
      Second = second; 
     } 
    } 

또는 # 4.0

보너스 C로 Tuple 클래스 :

public class VTriple<TFirst, TSecond, TThird> : VPair<TFirst, TSecond> 
    { 
     public TThird Third { get; set; } 

     public VTriple(TFirst first, TSecond second, TThird third) 
      : base(first, second) 
     { 
      Third = third; 
     } 
    } 
5

아니요.

배열이나 맵을 사용하여 반환 할 수 있습니다.

+1

+1 - 가장 정숙한 해결책은 질문에서 배제됩니다! – Fenton

0

당신은> 목록 < 객체를 반환 할 수 있습니다.

1

C++에서 std :: pair라는 이름으로이 작업을 수행 할 수 있습니다. C#으로 그것을 수행하는 방법에 StackOverflow의 게시물이 있습니다 : What is C# analog of C++ std::pair?

관련 문제