简体   繁体   中英

Console.Write deletable characters

Is there a way to write to Console a deletable char?

Eg

// input request
Console.Write("Enter session number: ");

// suggestion input that could be deleted by user
Console.WriteDeletable(currentSessionId)

This should output something like:

Enter session number: 2514656

Then the user may want to delete the integer part and type its own session id.

Enter session number: 251← ← ← ←

Is there such thing?

NB: I don't want to delete chars programmatically (ie via Write("\\b") ), I want them to be deletable from console window.

This will work:

    Console.Write("Enter session number:");
    SendKeys.SendWait("2514656"); //editable
    var sessionNumber = Console.ReadLine();

We simulate the user sending 2514656 so that the console will wait for user return input before the input is collected into the sessionNumber variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM