Share via


separate output text lines with blank lines in the console (without writing console.writeline() 3 times) - how?

Question

Monday, October 17, 2016 11:43 PM

I have done this before but I cannot for the life of me remember how. I want to do a console.WriteLine as follows:

--output:

sdkjasd;k asdkja;sdklj;asdklfj;klasdf

as;lkjas;dljk;sd;ksdlj;asd

asdlkjasd;jkas;dklj;kjsds

these output lines are separated by 3 blanks lines apiece. I don't want to write Console.WriteLine() 3 times per output line. I think I did something like Console.WriteLine(Environment.NewLine...pseudocode(3)) something like that. How can I add the 3 blank lines in one Console.WriteLine(...) ? Is it a format function? I just can't remember.



Rich P

All replies (4)

Tuesday, October 18, 2016 1:34 AM

Hi Rich P123,

Thank you for posting here.

For your question, you could use console.writeline() for one time with "\n". The use of Environment.NewLine Property could get the same output.

Please try the following code. 

            Console.WriteLine("sdkjasd;k asdkja;sdklj;asdklfj;klasdf" + "\n" + "as;lkjas;dljk;sd;ksdlj;asd" + "\n" + "asdlkjasd;jkas;dklj;kjsds");
            Console.WriteLine("sdkjasd;k asdkja;sdklj;asdklfj;klasdf{0}as;lkjas;dljk;sd;ksdlj;asd{0}asdlkjasd;jkas;dklj;kjsds", Environment.NewLine);

Here is the output.

I hope this would be helpful to you.

If you have something else, please feel free to contact us.

Best Regards,

Wendy

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.


Tuesday, October 18, 2016 3:16 PM

Thank you for your reply - it's not exactly what I was looking for, but I suppose I could do this:

Console.WriteLine("\n\n\n");

I thought there was some function, but the "\n" thing will suffice.

Rich P


Tuesday, October 18, 2016 3:44 PM

Hi Rich P123,

Thank you for feedback.

If it solves your problem, please mark as answer. This would make answer searching easier in the forum and be beneficial to community members as well.

There is two ways mentioned in my reply.

1."\n"

2. Environment.NewLine Property

If it could not solve your problem, please provided more details for us to give you a solution.

Best Regards,

Wendy

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.


Tuesday, October 18, 2016 10:59 PM | 1 vote

Greetings Rich.

I think you are looking for something like so...

Console.WriteLine("{0}{0}{0}", Environment.NewLine);