C# 如何禁用控制台应用程序中的每个文本输入

C# 如何禁用控制台应用程序中的每个文本输入,c#,tcp,console,C#,Tcp,Console,我的问题是如何完全禁用控制台应用程序的输入 它用于TCP服务器,我不想在控制台中输入somethinks 目前我有: for (int i = 0; i < 500; i++){ Console.ReadKey(true); } for(int i=0;i

我的问题是如何完全禁用控制台应用程序的输入

它用于TCP服务器,我不想在控制台中输入somethinks

目前我有:

for (int i = 0; i < 500; i++){
    Console.ReadKey(true);
}
for(int i=0;i<500;i++){
Console.ReadKey(true);
}
但这不是真的很好(必须等待500次按回车键,然后应用程序才能继续)

对不起,我的英语不好,希望有人能帮助我


最美好的祝愿

在本例中
控制台。ReadKey(true)
将接受按下的键,并且不会显示用户的输入

class Writer
{
    public void WriteLine(string myText)
    {
        for (int i = 0; i < myText.Length; i++)
        {
            if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Enter)
            {
                Console.Write(myText.Substring(i, myText.Length - i));
                break;
            }
            Console.Write(myText[i]);
            System.Threading.Thread.Sleep(pauseTime);
        }
        Console.WriteLine("");
    }
}
类编写器
{
公共无效写线(字符串myText)
{
for(int i=0;i