I am trying to convert an item from a text box which contains double numbers such as “1.1”. Is there a way in which I can format this, so that the “.1” will be removed and it can be assigned to the variable “points”?
Is there a way in which I can convert an item from the text box “txtTotal” which inside it will contain “1.1” to be formatted to hold the numbers before the point and then be assigned into the points variable, and points will then output “1”?
int points;
txtTotal.Text = string.Format("£{0:0}");
points = Convert.ToInt32(txtTotal.Text);
MessageBox.Show("{points}");
Thanks for the Help!
You can try to
Splitthe Text on the decimal point, then remove the£from the first array index usingTrimStart., and I would useint.TryParseto check if the output is valid.Like this: