Teejay
Teejay

Reputation: 7469

Console.Write deletable characters

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

E.g.

// 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 (i.e. via Write("\b")), I want them to be deletable from console window.

Upvotes: 1

Views: 86

Answers (1)

Marcus
Marcus

Reputation: 8669

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.

Upvotes: 4

Related Questions