简体   繁体   English

如何转换清单 <KeyValuePair<int,int> &gt;转换为int [] []?

[英]How to convert List<KeyValuePair<int,int>> to int[][]?

Is there an easy way like some combination with ToArray() function? 有没有简单的方法,例如与ToArray()函数的某种组合? I know it's possible to do this manually, but it's quite complex. 我知道可以手动执行此操作,但这非常复杂。

Or maybe there are some better way to create dynamic structur which collect some count of <int,int> pairs, and it's possible to convert it to int[][] at the end? 或者,也许有更好的方法来创建动态结构,该结构收集一些<int,int>对,然后可以将其最终转换为int[][]

尝试这个:

var result = list.Select(x => new[] { x.Key, x.Value }).ToArray();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM