using System.Text.RegularExpressions;
public static void Main()
Regex regex = new Regex(@"^-?[0-9][0-9,\.]+$");
Console.WriteLine("Nhap so nguyen co 3 chu so");
if (s.Length == 3 && regex.IsMatch(s))
int tong = Convert.ToInt16(s[0].ToString())
+ Convert.ToInt16(s[2].ToString());
int tich = Convert.ToInt16(s[0].ToString())
* Convert.ToInt16(s[2].ToString());
Console.WriteLine("Tong & tich so dau va cuoi la: {0} & {1}", tong, tich);
else { Console.WriteLine("Hay nhap so co 3 chu so"); }
} while (s.Length != 3 || !regex.IsMatch(s));