Write() and WriteLine() in C#

I have been following some tutorial of C# and encountered an issue of Write() and WriteLine() function. What is the difference between them?

They both print text on the console, but they operate differently based on new line character. Write() display the text without providing a new line character; whereas WriteLine() provides us with a new line character.

Talk Is Cheap, Show Me The Code


Console Output


Line 3 and line 4 is not on the same line, as WriteLine() provides a new line character. There is no pro and con between these two functions; it really depends on the purpose of your code.



Leave a Reply

Your email address will not be published. Required fields are marked *