Tuple
उदाहरण
आइए अब हम 2-टुपल को C# -
. में लागू करने के लिए एक उदाहरण देखेंusing System;
public class Demo {
public static void Main(string[] args) {
Tuple<string,string> tuple = new Tuple<string,string>("jack", "steve");
Console.WriteLine("Value = " + tuple.Item1);
if (tuple.Item1 == "jack") {
Console.WriteLine("Exists: Tuple Value = " +tuple.Item1);
}
if (tuple.Item2 == "david") {
Console.WriteLine("Exists: Tuple Value = " +tuple.Item2);
}
}
} आउटपुट
यह निम्नलिखित आउटपुट देगा -
Value = jack Exists: Tuple Value = jack
उदाहरण
आइए अब 2-टुपल को C# -
. में लागू करने के लिए एक और उदाहरण देखेंusing System;
public class Demo {
public static void Main(string[] args) {
Tuple tuple = new Tuple(20, "steve");
Console.WriteLine("Value = " + tuple.Item1);
if (tuple.Item1 == 20) {
Console.WriteLine("Exists: Tuple Value = " +tuple.Item1);
}
if (tuple.Item2 == "david") {
Console.WriteLine("Exists: Tuple Value = " +tuple.Item2);
}
}
} आउटपुट
यह निम्नलिखित आउटपुट देगा -
Value = 20 Exists: Tuple Value = 20