Try Parse


what difference between following 2 code snippets,

int32.try parse fails 1st sample, decimal.try parse succeeds both samples giving output of -50. bit confused why value of 50- (i.e. minus sign -) after 50 okay decimal not int32? extracting value excel sheet , doing conversion. 

  string value = "50-";  decimal v = 0;  decimal.tryparse(value, out v);    vs    string value = "-50";  decimal v = 0;  decimal.tryparse(value, out v);  


regards, vinay

hi vinay,

        string value = "50-";       decimal v;       numberstyles styles = numberstyles.allowdecimalpoint |          numberstyles.allowtrailingwhite |          numberstyles.allowleadingsign |          numberstyles.allowthousands;        decimal.tryparse(value, styles , cultureinfo.currentculture, out v);  
kind regards,


aelassas.free.fr


Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

How to Share webservice object to all user

How to fix error Msg 1801, Level 16, State 3, Line 1