小编Mat*_*hew的帖子

将对象列表转换为元组数组

有一个元组数组和对象列表定义为:

Tuple<string, string, string>[] phone_type 
List<Tele> telecomm

 public class Tele
{   public string number;
    public string displayNumber;
    public string type;
}
Run Code Online (Sandbox Code Playgroud)

我想将元素中存在的值分配给List<Tele>元组数组.以下代码不起作用.

obj.phone_type[0] = (Tuple<string,string,string>) obj1.telecommunication[0];
Run Code Online (Sandbox Code Playgroud)

错误说cast是多余的,无法转换ListTuple<string,string,string>

是否有一种干净的方法将List的特定/所有元素分配给元组数组.

.net c# linq tuples list

-1
推荐指数
1
解决办法
1536
查看次数

标签 统计

.net ×1

c# ×1

linq ×1

list ×1

tuples ×1