Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string Product_Name(string name)
- {
- try
- {
- if (!Regex.IsMatch(name, @"^[a-zA-Z]+$"))
- return name;
- }
- catch (StringFormatException sfe)
- {
- Console.WriteLine("String Format Exception " + sfe.Message);
- }
- }
- public int Quantity(string qty)
- {
- try
- {
- if (!Regex.IsMatch(qty, @"^[0-9]"))
- //Exception here
- return Convert.ToInt32(qty);
- }
- catch (NumberFormatException nfe)
- {
- Console.WriteLine("Number Format Exception " + nfe.Message);
- }
- }
- public double SellingPrice(string price)
- {
- try
- {
- if (!Regex.IsMatch(price.ToString(), @"^(\d*\.)?\d+$"))
- //Exception here
- return Convert.ToDouble(price);
- }
- catch (CurrencyFormatException cfe)
- {
- Console.WriteLine("Currency Format Exception " + cfe.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement