Tuple.cs 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. public static class Tuple
  3. {
  4. public static Tuple<T1, T2> Create<T1, T2>(T1 item1, T2 second)
  5. {
  6. return new Tuple<T1, T2>(item1, second);
  7. }
  8. public static Tuple<T1, T2, T3> Create<T1, T2, T3>(T1 item1, T2 second, T3 third)
  9. {
  10. return new Tuple<T1, T2, T3>(item1, second, third);
  11. }
  12. public static Tuple<T1, T2, T3, T4> Create<T1, T2, T3, T4>(T1 item1, T2 second, T3 third, T4 fourth)
  13. {
  14. return new Tuple<T1, T2, T3, T4>(item1, second, third, fourth);
  15. }
  16. public static void Unpack<T1, T2>(this Tuple<T1, T2> tuple, out T1 ref1, out T2 ref2)
  17. {
  18. ref1 = tuple.Item1;
  19. ref2 = tuple.Item2;
  20. }
  21. public static void Unpack<T1, T2, T3>(this Tuple<T1, T2, T3> tuple, out T1 ref1, out T2 ref2, T3 ref3)
  22. {
  23. ref1 = tuple.Item1;
  24. ref2 = tuple.Item2;
  25. ref3 = tuple.Item3;
  26. }
  27. public static void Unpack<T1, T2, T3, T4>(this Tuple<T1, T2, T3, T4> tuple, out T1 ref1, out T2 ref2, T3 ref3, T4 ref4)
  28. {
  29. ref1 = tuple.Item1;
  30. ref2 = tuple.Item2;
  31. ref3 = tuple.Item3;
  32. ref4 = tuple.Item4;
  33. }
  34. }