Width of Console.WriteLine("Size of {0} ", lnSize)

  • Thread starter Thread starter Roy Gourgi
  • Start date Start date
R

Roy Gourgi

Hi,

How would I set the width of lnSize to 6 in the statement

Console.WriteLine("Size of {0} ", lnSize);

Furthermore is there a way to combine these 3 statements into 1

Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

TIA
Roy
 
The \n escape character denotes a new line when in a string... so if you
replaced your 3 Console.WriteLine() calls with a single
Console.Write("\n\n\n") or even just Console.WriteLine("\n\n") you will end
up with the same output.

As for specifying the width of lnSize... in what way? The # of characters
being displayed when it is output?

Brendan
 
Hi Brendan,

Thanks for the Console.WriteLine("\n\n\n").

I solved the width problem by doing this:
Console.WriteLine("Size of {0,6} ", lnSize);

Roy
 
Brendan Grant said:
The \n escape character denotes a new line when in a string... so if you
replaced your 3 Console.WriteLine() calls with a single
Console.Write("\n\n\n") or even just Console.WriteLine("\n\n") you will end
up with the same output.

Not quite. Console.WriteLine uses the current line terminator, as
specified by Environment.NewLine. On Windows, that's "\r\n".
 
Back
Top