How I'll assign the string x = "490.00 001.09 987.1 876.99" into
x1 = "490.00"
x2 = "001.09"
x3 = "987.1"
x4 = "876.99"
Please advice me.. tnx!
You can use the String.Split Method which splits the string by a separator character into multiple parts. The default separator is any whitespace character:
string x = "490.00 001.09 987.1 876.99";
string[] parts = x.Split();
string x1 = parts[0];
string x2 = parts[1];
string x3 = parts[2];
string x4 = parts[3];
In your very specific case, this will work:
var x = "490.00 001.09 987.1 876.99";
var parts = x.Split(new char[] { ' ' });
var x1 = parts[0];
var x2 = parts[1];
var x3 = parts[2];
var x4 = parts[3];
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