सबसे पहले, टुपल में दो आइटम सेट करें।
Tuple<int, string> tuple = new Tuple<int, string>(20, "Tom");
अब टपल में पहले आइटम की जांच करें, जो एक पूर्णांक है।
if (tuple.Item1 == 20) {
Console.WriteLine(tuple.Item1);
} अब टपल में दूसरे आइटम की जांच करें, जो एक स्ट्रिंग है -
if (tuple.Item2 == "Tom") {
Console.WriteLine(tuple.Item2);
} स्ट्रिंग और इंट आइटम के साथ टपल बनाने के लिए निम्नलिखित एक उदाहरण है।
उदाहरण
using System;
using System.Threading;
namespace Demo {
class Program {
static void Main(string[] args) {
Tuple<int, string> tuple = new Tuple<int, string>(20, "Tom");
if (tuple.Item1 == 20) {
Console.WriteLine(tuple.Item1);
}
if (tuple.Item2 == "Tom") {
Console.WriteLine(tuple.Item2);
}
}
}
} आउटपुट
20 Tom