Home
Manage Your Code
Snippet: Test string for decimal (C#)
Title: Test string for decimal Language: C#
Description: Tests a string value to make sure it converts to a decimal. Writes to a label if it fails. Change variable names and use. Views: 163
Author: David Ashworth Date Added: 10/2/2007
Copy Code  
1 try
2            {
3                iOriginalPrice = decimal.Parse(sOriginalPrice);
4            }
5            catch (Exception ex)
6            {
7                lMessage.Text = "Could not convert " + sOriginalPrice + "to a valid price. Please re-enter";
8                return;
9            }