[英]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.