Here's my problem, I'm trying to format a {"C:O"} into a console.readline but I'm getting a method name expected error. here's what I have now:
money = double.Parse(Console.ReadLine()(string.Format("{O:C}")));
Here's my problem, I'm trying to format a {"C:O"} into a console.readline but I'm getting a method name expected error. here's what I have now:
money = double.Parse(Console.ReadLine()(string.Format("{O:C}")));
Copyright © 2021 Jogjafile Inc.
In addition to the syntax errors, you should generally use
decimalto represent money, since many operations ondoublecan result in round-off errors.I'd recommend something like this:
Or in one line:
But
Parsewill throw an exception if given invalid input (e.g."foo"). You might want to useTryParseto be a bit safer: