Jump to content

Duvida de de console.writeline


Moneybag
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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  👍😁

Link to comment
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
 Share

×
×
  • 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.