Question about Console Write() & WriteLine() methods

  • Thread starter Thread starter Unemployed VC++ guy
  • Start date Start date
U

Unemployed VC++ guy

It seems that there is basically no difference between the Console.Write() &
String.Format(), other than the output being sent to the console output stream
instead of a string. Is this accurate?

String formatter = "(whatever)";

Console.Write(formatter,object1,object2, ... );

String formattedString = String.Format(formatter,object1,object2, ... );

// Basically, formattedString will be exactly the same as what was put to the
console

Also, is there any difference between Write() & WriteLine(), other than a new
line?

String thankU = "Thanks";
Console.WriteLine(thankU);
 
Hi,

I believe String.Format is mainly for backwards compatibility (or rather
for people familiar with String.Format to begin with) as assembling
complex strings in .net can be done by simple string concatenation and
ToString() in a more readable manner.

And no, WriteLine adds a linebreak at the end, otherwise they are the same.
 
Back
Top