Difference between Parse/TryParse/ParseExact/TryParseExact
Parse ===== //int.Parse("12.44"); //Exception : Above code will generate the exception "Input string was not in a correct format", just because you are trying to cast float/real value in int[Integer]. //Only it is parsing if your parameter value must match the desire type in which you are trying to parse. TryParse ======== //case #1 int.TryParse("14.55",out a); //case #2 int.TryParse("14", out a); //Above code(case 1) will return 'false', just because parsing operation gets failed and value for variable 'a' would be 'zero' //here consider 'a' is output type of parameter like we have in oracle/sql server(not exactly same but behavior is same). //if parsing get succeeded than it will return true and target variable (i.e. 'a') will have the
Comments
Post a Comment