题目要求:

class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入正确的邮箱地址,以 @sina.com 结尾");
string us =Convert.ToString(Console.ReadLine());
string str1 = us.Replace("@", "");
int count = us.Length - str1.Length;
string str2 = us.Replace(".", "");
int count2 = us.Length - str2.Length;
int count3 = us.Length - 1;
int xl=us.IndexOf(".")-us.IndexOf("@");
bool mw = (us.IndexOf("@sina.com") == (us.Length-9));
while (count == 1 && count2 == 1 && us.IndexOf("@") > 0 && us.IndexOf(".") > us.IndexOf("@")
&& us.IndexOf(".")<count3)
{
if (xl != 1 && us.Contains("@sina.com") && mw)
{
Console.WriteLine("正确");
}
else {
Console.WriteLine("输入的邮箱地址有误");
}
break;
}
Console.ReadLine();
}
}