c# - Novice enquiry on using TryParse() properly -
c# - Novice enquiry on using TryParse() properly -
i've tried tryparse
, , new c# , trying understand everything, , best practices...
syntactically works:
double number = double.parse(c.readline());
does tryparse homecoming boolean, true if parse succeeds?
when this:
double number; bool b = double.tryparse(c.readline(), out number);
number
parsed input, c.readline()
, expected, works. how tryparse used? trying efficient, appreciate advice this.
any advice on approach welcome, plus info on online resources try(things).
you utilize tryparse
when may fail, , don't want code throw exception.
for example
if (!double.tryparse(someinput, out number)) { console.writeline("please input valid number"); }
c#
Comments
Post a Comment