title: Loading richTextBox text into an array
body: <p>I have a following question, as I am just starting to learn C#.</p>
  
  <p>I have a class defined like this:</p>
  
  <pre><code>public class Piksel
      {
          public int r;
          public int g;
          public int b;
      }
  </code></pre>
  
  <p>I then declare an array like so:</p>
  
  <pre><code>Piksel[,] tab2 = new Piksel[32, 32];
  </code></pre>
  
  <p>Now, I have a *.txt file in the following format:</p>
  
  <pre><code>...
  
  X: 15 , Y: 2 , R: 255 , G: 255 , B: 255
  
  X: 16 , Y: 2 , R: 183 , G: 183 , B: 183
  
  X: 17 , Y: 2 , R: 32 , G: 32 , B: 32
  
  X: 18 , Y: 2 , R: 32 , G: 32 , B: 32
  
  X: 19 , Y: 2 , R: 159 , G: 159 , B: 159
  
  X: 20 , Y: 2 , R: 255 , G: 255 , B: 255
  
  ...
  </code></pre>
  
  <p>I load it into a richTextBox:</p>
  
  <pre><code> OpenFileDialog openF1 = new OpenFileDialog();
          openF1.InitialDirectory = "C:\\Users\\Nagash\\Desktop";
          openF1.Title = "Wybierz plik z danymi obrazka";
          openF1.DefaultExt = "*txt";
          openF1.Filter = "Pliki TXT|*txt";
  
          if (openF1.ShowDialog() == System.Windows.Forms.DialogResult.OK &amp;&amp; openF1.FileName.Length &gt; 0)
          {
              richTextBox3.LoadFile(openF1.FileName,RichTextBoxStreamType.PlainText);
          }
  </code></pre>
  
  <p>And now my question: how can I put that data in the tab2 array from the richTextBox. For example, if a line in richTextBox reads</p>
  
  <pre><code>X: 15 , Y: 2 , R: 255 , G: 255 , B: 255
  </code></pre>
  
  <p>then what i want is the following result:</p>
  
  <pre><code>tab2[15,2].r=255 tab[15,2].g=255 tab[15,2].b=255
  </code></pre>
  
  <p>I treid fiddling with regular expressions like so:</p>
  
  <pre><code>MatchCollection mc = Regex.Matches(richTextBox3.Text, "[0-9]+");
          foreach (Match str in mc)
              richTextBox1.Text= richTextBox1.Text + Convert.ToString(str);
  </code></pre>
  
  <p>But then I am unsure how to tell if a number is 255 or is it 25 and a 5. Also still unsure how to put it into the array.</p>
  
  <p>Thanks for help.</p>