for converting string in decimal

Posted by Rock_Monu under ASP.NET on 11/7/2012 | Points: 10 | Views : 2508 | Status : [Member] | Replies : 3
How to convert a string into decimal in asp.net.




Responses

Posted by: Sandhyab on: 11/7/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Use decimal.parse for converting

Thanks & Regards
Sandhya

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 11/8/2012 [Member] Starter | Points: 25

Up
0
Down
decimal d = decimal.Parse("12.50");

Or

decimal d = decimal.Parse("12.00", CultureInfo.InvariantCulture);

Hope this helps



Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saratvaddilli on: 11/8/2012 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Decimal.parse may not work in all the cases

Please go through this

public static decimal ToDecimal(

string value
)

example
decimalVal = System.Convert.ToDecimal(stringVal);
)



Thanks and Regards
V.SaratChand
Show difficulties that how difficult you are

Rock_Monu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response