Код: Выделить всё
namespace ExtensionMethodAssignment
{
public class CheckID
{
public bool IsAllowedID(string id)
{
string specialChar = @"!@#$%^&*";
foreach (var identification in specialChar)
{
if(id.Contains(identification)) return true;
}
return false;
}
}
static void Main(string[] args)
{
Console.WriteLine("Type your ID : ");
string id = Console.ReadLine();
if (id.IsAllowedID() == true)
{
Console.WriteLine("ID is not allowed. \n !, @, #, $, %, ^, &, and * are not allowed.");
}
else
{
Console.WriteLine($"{id} is allowed.");
}
}
}
}
Думаю, это похоже на создание простого пустого объекта. имя метода IsAllowedID, а затем добавить метод Main, но я не знаю, как это сделать.
Подробнее здесь: https://stackoverflow.com/questions/788 ... -special-c