|
stringを分割してみた。ちょちょいといじればbyte[] に使えます。
using System;
using System.Collections.Generic;
public class Program {
public static IEnumerable<string> split(string str, params int[] col) {
int pos = 0;
foreach ( int c in col ) {
yield return str.Substring(pos, c);
pos += c;
}
}
public static void Main() {
string input = "abcdefghijklmnopqrstuvwxy" +
"ABCDEFGHIJKLMNOPQRSTUVWXY" +
"abcdefghijklmnopqrstuvwxy" +
"ABCDEFGHIJKLMNOPQRSTUVWXY";
foreach ( string item in split(input, new int[] {2,3,5,7,8,5,10,20,40}) ) {
System.Console.WriteLine("[{0}]", item);
}
}
}
|