相关疑难解决方法(0)

使用LINQ将集合拆分为`n`部分?

有没有一种很好的方法可以n使用LINQ 将集合拆分为多个部分?当然不一定均匀.

也就是说,我想将集合划分为子集合,每个子集合包含元素的子集,其中最后一个集合可以是不规则的.

.net c# linq data-structures

121
推荐指数
6
解决办法
7万
查看次数

从给定范围拆分数组

什么是从给定范围拆分数组的C#代码.例如:

int[] arr = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
Run Code Online (Sandbox Code Playgroud)

我想把arr它分成两个数组.一个从0到5指数,另一个从第6到第20指数.

在Java Arrays.copyOfRange()中可以用于此过程.这是什么C#代码?

c# arrays split

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

将字符串数组拆分为多个部分

我可以半信半疑,但我想要一个干净的方式做到这一点,以后不会产生任何麻烦.

private String[][] SplitInto10(string[] currTermPairs)
{
   //what do i put in here to return 10 string arrays
   //they are all elements of currTermPairs, just split into 10 arrays.
}
Run Code Online (Sandbox Code Playgroud)

所以我基本上想把一个字符串数组(currTermPairs)分成10或11个不同的字符串数组.我需要确保没有数据丢失并且所有元素都已成功传输

编辑:你得到一个n大小的字符串数组.需要发生的是该方法需要从给定的字符串数组返回10个字符串数组/列表.换句话说,将数组拆分为10个部分.

例如,如果我有

 A B C D E F G H I J K L M N O P Q R S T U
Run Code Online (Sandbox Code Playgroud)

我需要它分裂成根据其大小10个字符串数组11个或字符串数​​组,所以在这种情况下,我将不得不

A B
C D
E F
G H 
I J
K L
M N 
O P 
Q R 
S T 
U   <--Notice this is the 11th …
Run Code Online (Sandbox Code Playgroud)

c# arrays sorting list

0
推荐指数
1
解决办法
6499
查看次数

标签 统计

c# ×3

arrays ×2

.net ×1

data-structures ×1

linq ×1

list ×1

sorting ×1

split ×1