It should be a simple code:
string qty = "211.0000";
Console.WriteLine(Int32.Parse(qty));
I tried to use Convert.ToInt32
or Int32.Parse
, but they all throw an error:
Error(s):
Exception in user code:
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at Rextester.Program.Main(String[] args)
Did I make any errors to define a string and give a value? I have tried use string
or String
to define the variable. It works if I use Console.WriteLine(Convert.ToInt32("211.0000"))
.
BTW I was testing in http://rextester.com/