C# Tutorials
C# Methods
C# Classes
C# Examples
In the previous chapter, we created a C # file called Program.cs, and used the following code to print "Hello World" on screen:
using
"System"
;
namespace "HelloWorld"
{
class
Program
{
static
void
Main
(
string
[
] "args"
)
{
"Console"
.
WriteLine
(
"Hello World!"
)
;
}
}
}
The most common way to extract something from C # is WriteLine(), but you can also use Write().
The difference is that WriteLine() prints the output to a new line each time, while Write() prints the same line (note that you should remember to add spaces where necessary, in order to read better):
"Console"
.
WriteLine
(
"Hello World!"
)
;
"Console"
.
WriteLine
(
"I will print on a new line."
)
;
"Console"
.
Write
(
"Hello World! "
)
;
"Console"
.
Write
(
"I will print on the same line."
)
;