I’m making a credit card processing form. The field in question is Name: (first and last).
What would some C# code look like that would take the text from a text box and split it, then assign each word (in this case first and last name) into two new strings?
E.g. txtName.Text = "John Doe"
After split
string fName = "John";
string LName = "Doe";
You can split the text on a character or string into a string array, and then pull the individual parts of the name out of the array. Like so:
But why not just have a separate text box for each part of the name? What if somebody puts their full name in the text box (i.e. you’d have three parts, not just two).