How to Convert string("1.0000") to int
You can convert it to Double first, and then convert to Int32
String s = "1.0000";
Double temp;
Boolean isOk = Double.TryParse(s, out temp);
Int32 value = isOk ? (Int32) temp : 0;
You can use the following:
string data = "1.0000";
int number
if(data.Contains('.'))
number = int.Parse(data.Substring(0, data.IndexOf('.'))); //Contains decimal separator
else
number = int.Parse(data); //Contains only numbers, no decimal separator.
Because 1.0000
has decimal places, first strip those from the string
, and then parse the string to int
.