I am using Visual Studio, I type in the first textbox for example Name:First/age:22 but if try other name it will not work. How to manipulate the string inputted by the user. Any advise what is the use for this scenario except this substring?
private void btnManipulate_Click(object sender, EventArgs e)
{
string stringmanipulate = inputString.Text;
resultName.Text = stringmanipulate.Substring(5, 5);
resultAge.Text = stringmanipulate.Substring(15, 2);
}
This is my example output
If I type this
This is the error
CodePudding user response:
You can use String.Split()
//stringArray[0] will be your original string up until / - "Name:blabla"
//stringArray[1] will be your original string after / - "age:22"
var stringArray = stringmanipulate.Split('/');
After that you can use String.Split()
again but with the ':' character and apply the same logic