- Менее 9 символов.
- Знак «+» в начале.
- Только цифры.
Код: Выделить всё
static void Main(string[] args)
{
Console.WriteLine("Enter a phone number.");
string telNo = Console.ReadLine();
if (Regex.Match(telNo, @"^(\+[0-9])$").Success)
Console.WriteLine("correctly entered");
else
Console.WriteLine("incorrectly entered");
Console.ReadLine();
}
Подробнее здесь: https://stackoverflow.com/questions/299 ... one-number
Мобильная версия