Skip to content

Instantly share code, notes, and snippets.

@cpereira7
Last active October 11, 2017 22:24
Show Gist options
  • Select an option

  • Save cpereira7/4e19fd1154424d63a50f99191c13ec81 to your computer and use it in GitHub Desktop.

Select an option

Save cpereira7/4e19fd1154424d63a50f99191c13ec81 to your computer and use it in GitHub Desktop.
private static string DadosInput()
{
ConsoleKeyInfo key;
string document = "";
Console.ForegroundColor = ConsoleColor.Green;
Console.Write("\nData: ");
Console.ForegroundColor = ConsoleColor.White;
do
{
key = Console.ReadKey(true);
if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
{
document += key.KeyChar;
Console.Write(key.KeyChar);
}
else
{
if (key.Key == ConsoleKey.Backspace && document.Length > 0)
{
document = document.Substring(0, (document.Length - 1));
Console.Write("\b \b");
}
}
}
while (key.Key != ConsoleKey.Enter);
return document;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment