this is the program
string[] words = TextBox1.Text.Split(' ');
string fName = words[0];
string lName = words[1];
TextBox2.Text = fName.ToString();
TextBox3.Text = lName.ToString();
i split the two word using space , but in a single word it have some error like "Index was outside the bounds of the array." then how to solve it
Loading

Sandeep Singh ShekhawatPosted Nov 20, 2012, 1:01 AM
string fName=string.Empty;
string lName = string.Empty;
string[] words = TextBox1.Text.Split(' ');
if (words.Length >= 2)
{
fName = words[0];
lName = words[1];
}
else
{
fName = words[0];
}
TextBox2.Text = fName.ToString();
TextBox3.Text = lName.ToString();