static bool isEmailText(string text)
{
int Idx = text.IndexOf('@');
int Idx2 = text.LastIndexOf('.');
if (Idx < 2)
{
return false;
}
if (text.Substring(Idx).IndexOf('.') < 0)
{
return false;
}
char C = text[0];
try
{
int x = Convert.ToInt32(C);
}
catch
{
return false;
}
if (text.Substring(Idx).Length < 2)
{
return false;
}
if (text.Substring(Idx2).Length < 2)
{
return false;
}
return true;
}
Console.WriteLine("Podaj email: ");
string text = Console.ReadLine();
if (isEmailText(text))
{
Console.WriteLine("Podano poprawny email");
}
else
{
Console.WriteLine("Podano niepoprawny email");
}
Wyświetlenia: 17