+ 2

difference between return and Console.WriteLine

What is the difference between return and Console.WriteLine/Console.Write??

13th Dec 2017, 10:25 PM
Sabiha Moradi
Sabiha Moradi - avatar
6 Réponses
+ 13
Console.WriteLine is used to display some data on the screen. Return completes the execution of the some function, but it is not necessary that any data will be shown on the screen.
13th Dec 2017, 11:13 PM
NezhnyjVampir
+ 10
You are welcome, @Sabiha😊
14th Dec 2017, 10:26 AM
NezhnyjVampir
+ 4
thanks, @NezhnyjVampir
14th Dec 2017, 7:12 AM
Sabiha Moradi
Sabiha Moradi - avatar
+ 4
@LunarCoffee I knew the difference of these two. my question was difference between these two and return. Anyhow thanks.
14th Dec 2017, 7:14 AM
Sabiha Moradi
Sabiha Moradi - avatar
+ 3
Console.Write() prints something to the screen without a newline at the end. Console.WriteLine() adds a newline to the end. In general, Console.WriteLine() is used more. To demonstrate: [------------------------------------------------] EXAMPLE 1: Console.Write("Hello, "); Console.Write("world!"); OUTPUT: Hello, world! [------------------------------------------------] EXAMPLE 2: Console.WriteLine("Hello, "); Console.WriteLine("world!"); OUTPUT: Hello, world! [------------------------------------------------] Hope that helps! :)
14th Dec 2017, 2:21 AM
LunarCoffee
LunarCoffee - avatar
+ 1
Oh, ok.
14th Dec 2017, 1:15 PM
LunarCoffee
LunarCoffee - avatar