XAML 我应该如何创建一个在调用方法时返回的列表,它包含两个列表,每个列表包含四个元组?[closed]

eoigrqb6  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(94)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
两年前就关门了。
Improve this question
我创建了一个包含两个列表的方法;每个列表都有四个元组,我希望在调用方法时返回两个列表。我尝试创建一个新列表来实现这一点,但它无法接受元组转换为列表。有没有办法将元组转换为列表?
我应该如何创建一个当方法被调用时返回的列表,它包含两个列表,每个列表包含四个元组?
下面是一个代码类似于我的工作:* 注意:我需要使用元组的原因是为了能够使用XAML访问和显示它们。

var listStudents1 = new List<Tuple<string, string, string>>

{

               Tuple.Create("A", "Roya Taymoor", "USA"),

               Tuple.Create("B", "Michael Stevens", "UK" ),

               Tuple.Create("C", "Steve Barnes", "UK" )

};
var listStudnets2 = new List<Tuple<string, string, string>>

{

               Tuple.Create("C", "Liam Cook", "USA"),

               Tuple.Create("D", "Arianda Reggi", "France" ),

               Tuple.Create("E", "Amy Ronald", "UK" )

}; 
StudentsLists.Add(listStudents1); //StudentsLists is a previously defnded property/list in the class that accepts string. 
StudentsLists.Add(listStudents2);
return StudentsLists;
polkgigr

polkgigr1#

只需在下面的示例中使用List<whateverYouWantToReturn>即可。

public  List<List<Tuple<string, string, string>>> GetStudents(){
    var listStudents1 = new List<Tuple<string, string, string>>

{
    Tuple.Create("A", "Roya Taymoor", "USA"),
    Tuple.Create("B", "Michael Stevens", "UK" ),
    Tuple.Create("C", "Steve Barnes", "UK" )

};
var listStudnets2 = new List<Tuple<string, string, string>>

{
  Tuple.Create("C", "Liam Cook", "USA"),
  Tuple.Create("D", "Arianda Reggi", "France" ),
  Tuple.Create("E", "Amy Ronald", "UK" )

};  
    var result = new  List<List<Tuple<string, string, string>>>();
    result.Add(listStudents1);
    result.Add(listStudnets2);
    return result;
}

相关问题