Similar to this question just in C# instead of JavaScript. I couldn’t find anything for C# while searching
I have a text box that will take a quantity, which is later stored as a double in a database. However it is possible that some quantities will be entered as string fractions e.g 1/2 for 0.5.
I want to be able to convert these to decimal before storing them to the database (being able to also convert back would be nice but not necessary). I want to be able to handle both fractions and mixed numbers e.g. 2 1/2 is saved as 2.5
Anybody know a way of doing this?
Try splitting it on the space and slash, something like:
Hey, it worked! Remember to check for a division by zero, too. You’ll get Infinity, -Infinity, or NaN as a result.