I have a string composed of 16 digits (a hexadecimal number), which will be entered in a textbox as one large number. For example, '1111222233334444".
I need to
I have found some methods to do this, but they just write to console. So after the user enters that data, I need to have something like:
string first = 1111;
string second = 2222;
string third = 3333;
string fourth = 4444.
Any help is appreciated!
You can do it with substring.
string strNumber = "1111222233334444";
string []strArr = new string[4];
for(int i=0; i < 4; i++)
{
strArr[i] = strNumber.Substring(i*4, 4);
}
Here it is:
string initial_string = TextBox1.Text; //read from textbox
string [] number = new string[4];
number[0] = initial_string.Substring(0,4);
number[1] = initial_string.Substring(4,4);
number[2] = initial_string.Substring(8,4);
number[3] = initial_string.Substring(12,4);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With