Timeline for Basic C# Calculator
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 25, 2023 at 16:07 | comment | added | radarbob | check that numberTwo is not zero when dividing => Catch the error at entry or at execution ( pressing '=') ? -> Catching during execution future-proofs the code. Adding operator chaining (3+1-2) and parentheses (operation precedence) will likely break existing code. You can't predict what the user will enter next or how a not-yet-completed expression will parse. | |
Apr 25, 2023 at 12:41 | comment | added | akinuri |
Also, there's no need to duplicate operations (WriteLine ). Logic should only modify the data. So create a result variable. Modify it as many times as you need. Print it once.
|
|
Apr 25, 2023 at 10:13 | comment | added | H. Pauwelyn |
Don't use try catch for converting numbers. Use double.TryParse instead. Try catch will have an impact on performance in duration each time the users enters an invalid number.
|
|
Apr 25, 2023 at 5:15 | comment | added | sbottingota | @CompuChip, is this what you mean (I have added a section). | |
Apr 25, 2023 at 5:15 | history | edited | sbottingota | CC BY-SA 4.0 |
Added more detail
|
S Apr 24, 2023 at 15:12 | history | suggested | CommunityBot | CC BY-SA 4.0 |
Added missing break statements
|
Apr 24, 2023 at 14:52 | review | Suggested edits | |||
S Apr 24, 2023 at 15:12 | |||||
Apr 24, 2023 at 14:42 | comment | added | minnmass |
As an alternative for the try/catch , you could also use double.TryParse . That would also simplify making the app loop until valid numbers are entered.
|
|
Apr 24, 2023 at 14:03 | comment | added | CompuChip |
And while you're at it (it being "error handling") you may want to check that numberTwo is not zero when dividing.
|
|
Apr 24, 2023 at 5:56 | vote | accept | Beefaroni2234 | ||
Apr 24, 2023 at 5:47 | history | edited | sbottingota | CC BY-SA 4.0 |
Made small changes.
|
Apr 24, 2023 at 5:29 | history | edited | sbottingota | CC BY-SA 4.0 |
Added more detail.
|
Apr 24, 2023 at 5:23 | history | answered | sbottingota | CC BY-SA 4.0 |