首页 > 解决方案 > C#如何在CMD中做出类似于SET /P的提示?

问题描述

如何在 CMD 中做出类似于 SET /P 的提示?

我正在尝试这样做:

(PATH VARIABLE): <user input here>

我将它用于我正在制作的 CMD shell 模拟器。

标签: c#

解决方案


使用此代码:

while (true)
{
    Console.Write("My Command : ");
    string input = Console.ReadLine();
    if (input.ToUpper() == @"SET /P")
        Console.WriteLine("command correct : " + input);
    else
        Console.WriteLine("command wrong : " + input);
}

推荐阅读