मैं tuples की एक सूची है:tuples की सूची में से विशिष्ट आइटम प्राप्त C#
List<Tuple<int, string, int>> people = new List<Tuple<int, string, int>>();
एक dataReader
का उपयोग करना, मैं विभिन्न मूल्यों के साथ इस सूची को पॉप्यूलेट हो सकता है: तो
people.Add(new Tuple<int, string, int>(myReader.GetInt32(4), myReader.GetString(3), myReader.GetInt32(5)));
लेकिन मैं कैसे करना है प्रत्येक व्यक्तिगत मूल्य प्राप्त करने के माध्यम से लूप। उदाहरण के लिए मैं एक विशिष्ट व्यक्ति के लिए 3 विवरण पढ़ना चाहता हूं। आइए कहें कि एक आईडी, एक नाम और एक फोन नंबर है। मैं निम्नलिखित की तरह कुछ हैं:
for (int i = 0; i < people.Count; i++)
{
Console.WriteLine(people.Item1[i]); //the int
Console.WriteLine(people.Item2[i]); //the string
Console.WriteLine(people.Item3[i]); //the int
}
लोग [i] .Item1, लोगों को [i] .Item2, लोगों को [i] .Item3 –