Console.ReadLine(“默认文本可编辑文本在线”)

有没有办法实现这个目标? 我想传递一些文本并让它出现在输入行 – 而不是“ 输入你的名字: ”,我想要“ 输入你的名字:默认可编辑文本

好的,找到了。 抱歉。

static void Main(string[] args) { Console.Write("Your editable text:"); SendKeys.SendWait("hello"); //hello text will be editable :) Console.ReadLine(); } 

将默认值分配给字符串,并仅在用户输入内容时替换它。

 Dim name, s As String name = "John" Console.Write($"Enter your Name (hit  for ""{name}""): ") s = Console.ReadLine() If Trim(s) <> "" Then name = s End If Console.WriteLine("Result = {0}", name) Console.ReadKey()