Both write() and writeline() are methods provided by system.console, which are mainly used to display the output stream from the specified output device (screen by default).
the differences between the two methods are as follows:
The console. Writeline() method outputs the string to be output together with the newline control character. When the next statement is executed, the cursor will move to the next line of the current output string.
as for the console. Write() method, the cursor will stop after the last character of the output string in C # tutorial, and will not move to the next line.
The difference between write() and writeline()
All the methods provided by system.console
are displayed on the screen
write() does not wrap after it is displayed, and writeline() wraps
code examples
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace The difference between WriteLine and Write
WriteLine
class Program
{
static void Main(string[] args)
{
//WriteLine output with mouse at the beginning of the next line
//Write output does not start a new line
System.Console.WriteLine("First WriteLine Line");
System.Console.WriteLine("Second WriteLine Line");
System.Console.Write("First Write Line");//Instead of starting a new line after the First Write Line, the output is directly followed by the Second Write Line
System.Console.Write("Second Write Line");
//passing parameters
System.Console.WriteLine("\nWriteLine:Parameter={0}", 123);
System.Console.Write("Write:Parameter={0}", 456);
System.Console.ReadKey();
}
}
}
output
First WriteLine Line
Second WriteLine Line
First Write LineSecond Write Line
WriteLine:Parameter=123
Write:Parameter=456
Here is the article about the difference between write() and writeline() in C #. For more information about CSharp write and writeline, please search the previous articles of script home or continue to browse the following related articles. I hope you can support them in the future
Read More:
- C language write() function analysis: write failed bad address
- The usage and difference of atoi() and stoi() functions in C + +
- Analysis of shadows a parameter exception in C + +
- C + + pauses the black window system (“pause”); (get ch(), getchar(), system (pause)’s connection and difference
- In C + + cin.getline The difference between () and getline () functions
- R language – error analysis – error in Call.graphics (C_ palette2, .Call(C_ palette2, NULL)) : invalid graphics state
- Could not write JSON: write javaBean error, fastjson version x.x.x, class
- C language string processing error warning, c4996, sprintf, predicted, c4996, strcpy, c4996, strcat
- The difference between LSTM and Gru
- The difference between sleep() and wait() in Java
- The difference between classnotfoundexception and NoClassDefFoundError
- The difference between problem and observables
- The difference between “?” and “?:” introduced by php7
- JavaScript summary: the difference between typeof and instanceof, and Object.prototype.toString() method
- Difference between vs code user and system version
- The difference and usage of insmod and modprobe
- Difference between getelementsbyname and getelementbyid
- Parsing the difference between “R” and “RB” patterns of text files (Python)
- The difference of. Pt,. PTH,. Pkl and the way to save the model
- Error analysis of receive comments before first target. Stop