Console.ReadLine( "Default Text Editable Text On Line" )



有办法做到这一点吗?我想传递一些文本并将其显示在输入行上,而不是"输入您的姓名:<cursor>",而是"Enter your Name:Default Editable text<游标>"

好的,找到了。对不起。

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 <Enter> for ""{name}""): ")
s = Console.ReadLine()
If Trim(s) <> "" Then
    name = s
End If
Console.WriteLine("Result = {0}", name)
Console.ReadKey()

相关内容

最新更新