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
decimal
to represent money, since many operations ondouble
can result in round-off errors.I'd recommend something like this:
Or in one line:
But
Parse
will throw an exception if given invalid input (e.g."foo"
). You might want to useTryParse
to be a bit safer: