Hey everyone! Happy New Year!
I am trying to hone my programming skills by writing simple applications. I created a very simple currency converter program (hard-coded exchange rates....so nothing special). I first created it as a console app, and then in WPF.
Anyway, I ran into an issue with the textbox that takes input. I wasn't sure what would be the best way to keep letters from being entered. After looking online at regular expressions, I wrote a basic regex using an if statement to keep invalid input from being entered:
If the input has letters, then a messagebox is prompted (after pressing a button) and I have that button's method set to clear the textbox.
*****So basically, the program works 100% properly, but I was wondering if using Regex was the "best" move as opposed to trying to implement a try-catch, which quite honestly, I do not understand how to use completely. I was reading something about SQL queries vs. LINQ (speed of returning results), etc. and was wondering if regex vs. try-catch was similar.
*If anyone wants to see some of the code, just let me know which parts you want to see or the whole program.