-1

I'm recovering the value of a website, however I'm having difficulty formatting the string ...

My Value: $314.623230
Expected result: 314.62

How i can archive this result?

I have tried to convert the string to decimal and use ToSting() with arguments (N0, N1, 0:0##), but it does not return the expected result ...

Sharp Always
  • 61
  • 2
  • 6

1 Answers1

0
var usCulture = new CultureInfo("en-US");
decimal d = decimal.Parse("$314.623230", NumberStyles.Currency, usCulture);
string expectedResult = d.ToString("0.##", usCulture); // 314.62
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939