class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
int firstIndex = str.IndexOf("@");
int lastIndex = str.LastIndexOf("@");
if(firstIndex != -1 && firstIndex == lastIndex)
{
str = str.Substring(0, firstIndex);
}
Console.WriteLine("邮箱中的用户名是:" + str);
}
}
本文介绍了一个使用C#实现的简单程序,该程序能够从输入的字符串中解析出邮箱地址的用户名部分。通过查找字符串中'@'符号的位置,程序能够确定用户名的边界并将其输出。
962

被折叠的 条评论
为什么被折叠?



