110,538
社区成员
发帖
与我相关
我的任务
分享
List<char> charList = new List<char>();
while (true)
{
while (Console.KeyAvailable)
{
var k = Console.ReadKey(true);
if (k.Key == ConsoleKey.Enter)
{
Console.WriteLine();
Console.WriteLine("已完成");
Console.WriteLine(string.Join(" ", charList));
}
if (charList.Contains(k.KeyChar))
{
Console.Write("已存在");
}
else
{
Console.Write(k.KeyChar);
charList.Add(k.KeyChar);
}
}
}
static void Main(string[] args)
{
List<string> list = new List<string>();
while(true)
{
string str = Console.ReadLine();
if (str == "")
{
Console.WriteLine("已经完成");
break;
}
var v = list.SingleOrDefault(x=>x == str);
if (v == null)
{
list.Add(str);
}
else
{
Console.WriteLine("已经存在");
}
}
foreach (var item in list)
{
Console.WriteLine(item);
}
Console.WriteLine("按任意键退出");
Console.ReadKey();
}
static void Main(string[] args)
{
List<string> list = new List<string>();
while(true)
{
string str = Console.ReadLine();
if (str == "")
{
Console.WriteLine("已经完成");
break;
}
var v = list.SingleOrDefault(x=>x == str);
if (v == null)
{
list.Add(str);
}
else
{
Console.WriteLine("已经存在");
}
}
foreach (var item in list)
{
Console.WriteLine(item);
}
Console.WriteLine("按任意键退出");
Console.ReadKey();
}
static void Main(string[] args)
{
List<string> list = new List<string>();
while(true)
{
string str = Console.ReadLine();
if (str == "")
{
Console.WriteLine("已经完成");
break;
}
var v = list.SingleOrDefault(x=>x == str);
if (v == null)
{
list.Add(str);
}
else
{
Console.WriteLine("已经存在");
}
}
foreach (var item in list)
{
Console.WriteLine(item);
}
Console.WriteLine("按任意键退出");
Console.ReadKey();
}