Empty String to Double C#

后端 未结 5 1144
误落风尘
误落风尘 2021-01-05 17:56

At this moment i am trying to get a double value from textbox like this:

String.IsNullOrEmpty(textBox1.Text) ? 0.0 : Double.Parse(textBox1.Text)
5条回答
  •  一向
    一向 (楼主)
    2021-01-05 18:46

    Why don't you just use Double.TryParse that doesn't throw exception?

提交回复
热议问题