gpt4 book ai didi

c# - 元组到元组的转换

转载 作者:太空宇宙 更新时间:2023-11-03 17:27:53 25 4
gpt4 key购买 nike

有什么简单的方法可以转换Tuple<int, string, Guid>吗?至 Tuple<int, string>

更新:... 转换 List<Tuple<int, string, Guid>>List<Tuple<int, string>>

最佳答案

确定:

Tuple<int, string, Guid> t1 = ...;
Tuple<int, string> t2 = new Tuple<int, string>(t1.Item1, t1.Item2);

更新:
随着列表:

List<Tuple<int, string, Guid>> t1s = ...;
List<Tuple<int, string>> t2s = t1s.Select(t1 => new Tuple<int, string>(t1.Item1, t1.Item2)).ToList();

关于c# - 元组到元组的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5498928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com