튜플 요소의 유형을 가져오기 위한 코드는 다음과 같습니다. -
예시
using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(150, 1500, Tuple.Create(50, 100)); var tuple2 = Tuple.Create(150, 1500, Tuple.Create(100, 200)); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple1.GetType()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple2.GetType()); } }
출력
이것은 다음과 같은 출력을 생성합니다 -
Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = 188892 Type of Tuple1 = System.Tuple`3[System.Int32,System.Int32,System.Tuple`2[System.Int32,System.Int32]] HashCode of Tuple2 = 191462 Type of Tuple1 = System.Tuple`3[System.Int32,System.Int32,System.Tuple`2[System.Int32,System.Int32]]
예시
이제 다른 예를 살펴보겠습니다 -
using System; public class Demo { public static void Main(String[] args){ var tuple1 = Tuple.Create(10, 20); var tuple2 = Tuple.Create(30, 40); Console.WriteLine("Is Tuple1 equal to Tuple2? = "+tuple1.Equals(tuple2)); Console.WriteLine("HashCode of Tuple1 = "+tuple1.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple1.GetType()); Console.WriteLine("HashCode of Tuple2 = "+tuple2.GetHashCode()); Console.WriteLine("Type of Tuple1 = "+tuple2.GetType()); } }
출력
이것은 다음과 같은 출력을 생성합니다 -
Is Tuple1 equal to Tuple2? = False HashCode of Tuple1 = 350 Type of Tuple1 = System.Tuple`2[System.Int32,System.Int32] HashCode of Tuple2 = 1014 Type of Tuple1 = System.Tuple`2[System.Int32,System.Int32]