C# 数组按照固定跨度, 间隔进行分组合并
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApp16
{
class Program
{
static void Main(string[] args)
{
// 数组
string[] arr = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" };
// 固定长度间隔
int space = 2;
int N = arr.Length;
for (int i = 0; i < N; i = i + space)
{
string temp = "";
int stop = i + space;
for (int j = i; j < (stop > N ? N : stop); ++j)
{
temp += arr[j] + ",";
}
// 输出合并
Console.WriteLine(temp);
}
Console.Read();
}
}
}