Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Use substring in c#?

Tags:

substring

c#

I have -$2.00 as the string. I am trying to change it to decimal by removing - and $ using substring, but I am doing it wrong. Can someone help me?

Thanks.

like image 309
Remo Avatar asked Aug 30 '26 13:08

Remo


1 Answers

string m = "-$2.00";
decimal d = Math.Abs(Decimal.Parse(m, NumberStyles.Currency));
like image 58
evilone Avatar answered Sep 01 '26 07:09

evilone