C# change multiple backcolor RichTextBoxes at once
<p>Been fooling around with C# and ran into something that I was stumped on. Essentially, I have multiple RichTextBoxes that I want to change backcolor of all at once with the click of a button. I know the quick and dirty way is to just:</p>

<pre><code>    richTextBox1.BackColor = Color.Green;
    richTextBox2.BackColor = Color.Green;
    ...
    richTextBoxn.BackColor = Color.Green;
</code></pre>

<p>But for something like 100+ boxes, I am trying to aim for something a little compact in terms of programming. I was looking into using a for loop to solve my problem:</p>

<pre><code>    var richTextBox = new RichTextBox[6];

        for (var i = 1; i &lt; 7; i++)
        {
            var s = new RichTextBox();

            this.Controls.Add(s);

            richTextBox[i].BackColor = Color.Green;
        }
</code></pre>

<p>But when I run the code, I get an exception issue of "An unhandled exception of type 'System.NullReferenceException' occurred..."</p>

<p>I hoping for a way to just change the backcolor of multiple RichTextBoxes/TextBoxes at once without having to write 100+ lines of code if I want to control 100+ backcolors at once.</p>