Friday, December 22, 2017

double.TryParse in C#


double.TryParse method is used to convert given string to its double-precision floating point number same like double.Parse but the main difference is that it does not throw exception even if the input is not in correct format or is null.

Syntax:
double.TryParse(string str, out returnValue);

str is Input string.
returnValue: double-precision floating point number equivalent to “str”.

If the conversion is successful, the given string in converted into double-precision floating point number otherwise 0 is returned to the out parameter.



This function returns true for successful conversion and false if conversion is failed. Every time there will be one of two results either 0 if failed or value if successful. There will not be any type of exception thrown by this function even if the input string is:

a)   Null                                      :        NO ArgumentNullException
b)   Not is correct format            :        NO FormatException
c)    Out of range                         :        NO OverflowException


Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: