Convert.ToInt32(float) fails when trying to convert float to Int32

前端 未结 4 978
情话喂你
情话喂你 2021-01-18 11:38

No exception is thrown, function just halts at this statement:

int productQuantity = Convert.ToInt32(\"1.00\");

and returns.

What

4条回答
  •  余生分开走
    2021-01-18 11:51

    An exception is thrown, it's just that to see it you have to inspect the RunWorkerCompletedEventArgs.Error property in the event handler for BackgroundWorker.RunWorkerCompleted.

    Any exception that is thrown from the background worker's thread when the background work is being done is assigned to that property.

提交回复
热议问题