Console.ReadLine(“Default Text Editable Text On Li

2019-01-26 07:18发布

Is there way of achieving this? I want to pass some text and have it appear on the input line -- instead of "Enter your Name:<cursor>", I want "Enter your Name:Default Editable Text<cursor>"

2条回答
我只想做你的唯一
2楼-- · 2019-01-26 07:32

Ok, found it. Sorry.

static void Main(string[] args)
{
    Console.Write("Your editable text:");
    SendKeys.SendWait("hello"); //hello text will be editable :)
    Console.ReadLine();
}
查看更多
Summer. ? 凉城
3楼-- · 2019-01-26 07:40

Assign the default value to your string and replace it only if the user has entered something.

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()
查看更多
登录 后发表回答