編集:Take / Skipメソッドを試しましたが、次のエラーが発生します:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<string>' to
'string[]'. An explicit conversion exists (are you missing a cast?)
Saeedのコードをコピーしたので、何が間違っているのかわかりません。
文字列配列(20から300のアイテムを含む)があり、最初の配列の中央から2つの別々の配列に分割したいと思います。
forループを使用してこれを行う方法は知っていますが、より高速でより良い方法があるかどうかを知りたいと思います。また、アイテムの数が奇数であっても、配列を正しく分割できる必要があります。例:
string[] words = {"apple", "orange", "banana", "pear", "lemon"};
string[] firstarray, secondarray;
SplitArray(words, out firstarray, out secondarray); // Or some other function
// firstarray has the first 3 of the items from words, 'apple', 'orange' and 'banana'
// secondarray has the other 2, 'pear' and 'lemon'