I have an IEnumerable
of objects of the following class:
class MyTuple
{
public string Left;
public string Right;
}
as myTuples
Is there any way, by lambda exp by which I could convert this into IEnumerable<Tuple<string, string>>
without a for each loop?
var newList = myTuples.Select(x => Tuple.Create(x.Left, x.Right));
var result = myTuples.Select(t => new Tuple<string, string>(t.Left, t.Rigth));
注意:我建议您使用具有比Tuple或自定义元组更多信息的名称和属性的类。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.