Jump to content
Moneybag

Duvida de de console.writeline

Recommended Posts

Moneybag

Boas Pessoal.

É possível escrever na mesma linha de uma consola, ou seja que não passe para a linha debaixo.

Mas que não incrementasse o texto que já esta escrito no ecrâm, como o console.write faz.

Share this post


Link to post
Share on other sites
Rechousa

Olá,

Podes fazer isso usando o \r (Carriage Return), exemplo:

static void Main()
{
Console.WriteLine("Progress:");
for (int i = 0; i <= 100; i++)
{
	Console.Write("\r{0}%", i);
	Thread.Sleep(50);
}
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Done!");
Console.ReadKey();
}


Pedro Martins

Sharing is Knowledge!

http://www.linkedin.com/in/rechousa

Share this post


Link to post
Share on other sites
Moneybag

Olá,

Podes fazer isso usando o \r (Carriage Return), exemplo:

static void Main()
{
Console.WriteLine("Progress:");
for (int i = 0; i <= 100; i++)
{
	Console.Write("\r{0}%", i);
	Thread.Sleep(50);
}
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Done!");
Console.ReadKey();
}

sim, é isso mesmo. obrigado  :thumbsup::cheesygrin:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.