Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing string at the same position using Console.Write in C# 2.0

Tags:

c#

.net

I have a console application project in C# 2.0 that needs to write something to the screen in a while loop. I do not want the screen to scroll because using Console.Write or Console.Writeline method will keep displaying text on console screen incremently and thus it starts scrolling.

I want to have the string written at the same position. How can i do this?

Thanks

like image 200
pradeeptp Avatar asked Nov 12 '08 11:11

pradeeptp


People also ask

What is console WriteLine () good for?

Write is used to print data without printing the new line, while Console. WriteLine is used to print data along with printing the new line.

What is the syntax to print a text in the console?

Console. WriteLine("This is C#"); In this code line, we print the "This is C#" string to the console. To print a message to the console, we use the WriteLine method of the Console class.

Which of the below statement is used to write to a console?

Which of the below statement is used to write to a console? log() is used to write on browser's console.

How does WriteLine () method works in C#?

WriteLine(String, Object, Object) Writes the text representation of the specified objects, followed by the current line terminator, to the standard output stream using the specified format information.


1 Answers

Use Console.SetCursorPosition to set the position. If you need to determine it first, use the Console.CursorLeft and Console.CursorTop properties.

like image 113
Jon Skeet Avatar answered Oct 05 '22 22:10

Jon Skeet