Split text typed into a text box into labels on another form
<p>I have already been able to split a first name and a last name. But the problem I am having is if someone decides to type in a middle initial or a middle name? Anyone know how I can go about doing this?</p>

<p>Here is the code I have so far:</p>

<pre><code>//Name Split
var fullname = strTextBox;
var names = fullname.Split(' ');           
label3.Text = names[0];
label5.Text = names[1] + " " + names[2];</code></pre>

<p>This code works if the person types in a middle initial and a a last name. But is the user only types in a first and last name, the <code>names[2]</code> gives me the error since it cannot find another partition.</p>

<p>I would say that I have spent at least 10 hours trying to figure out a conditional to get this to work, but have not gotten it yet.</p>

<p>Here is one of the many conditionals I have tried:</p>

<pre><code>//Name Split
var fullname = strTextBox;
var names = fullname.Split(' ');
if (fullname.Contains (&gt; 1 (' '))
{
    label3.Text = names[0]; // first
    label5.Text = names[1] + " " + names[2]; // middle initial
}
else
{
    label3.Text = names[0];
    label5.Text = names[1];
}</code></pre>
