简体   繁体   中英

C# - copying from a jagged array to a jagged array with data changes

I want to take the phrases that are stored in jagged array number one to break those phrases into individual words and put them into another jagged array. how to make it work?

I was able to put the data from a one-dimensional array into a jagged array, that is, break the sentence into phrases:

string[][] phrases;
{
  phrases = new string[sentences.Length][];
  char[] charRemover = { ',', ':' };

  for (int i = 0; i < sentences.Length; i++)
  {
     phrases[i] = sentences[i].Split(charRemover);
  }
}

but I could not break the phrases into words, that is, put the data from one gear array into another! tell me please how to do it

Full code

I found a way to copy the data of a gear array to another gear with the 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[][] 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(" ", "");
                }
            }
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM