[英]C# - copying from a jagged array to a jagged array with data changes
我想將存儲在第一個鋸齒狀數組中的短語分解成單獨的單詞並將它們放入另一個鋸齒狀數組中。 如何讓它發揮作用?
我能夠將一維數組中的數據放入鋸齒狀數組中,即將句子分解為短語:
string[][] phrases;
{
phrases = new string[sentences.Length][];
char[] charRemover = { ',', ':' };
for (int i = 0; i < sentences.Length; i++)
{
phrases[i] = sentences[i].Split(charRemover);
}
}
但我無法將短語分解成單詞,即將數據從一個齒輪陣列放入另一個齒輪陣列! 請告訴我該怎么做
我找到了一種方法,可以將一個齒輪陣列的數據隨着數據的變化復制到另一個齒輪
string[][] phrases;
{
phrases = new string[sentences.Length][];
char[] charRemover = { ',', ':' };
for (int i = 0; i < sentences.Length; i++)
{
phrases[i] = sentences[i].Split(charRemover);
}
}
string[][] words;
{
words = new string[phrases.Length][];
for (int y = 0; y < phrases.Length; y++)
{
// Initialize Array
words[y] = new string[phrases[y].Length];
// For each Column
for (int x = 0; x < words[y].Length; x++)
{
words[y][x] = phrases[y][x].Replace(" ", "");
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.