C# Extension Method for String Data Type

Posted by Jimbo on Stack Overflow See other posts from Stack Overflow or by Jimbo
Published on 2010-05-04T08:56:31Z Indexed on 2010/05/04 9:08 UTC
Read the original article Hit count: 160

My web application deals with strings that need to be converted to numbers alot - users often put commas, currency symbols etc. in these fields so what I want to do is create a string extension method that cleans the field up and converts it to a decimal.

For example:

decimal myNumber = "$1,250.85".ToDecimal();

Can anyone help with this? Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about extension-methods