在控制台中用空白行分隔输出文本行(不编写console.writeline()3次)-怎么做? [英] separate output text lines with blank lines in the console (without writing console.writeline() 3 times) - how?

查看:240
本文介绍了在控制台中用空白行分隔输出文本行(不编写console.writeline()3次)-怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前曾经做过此事,但我一生都无法记住如何做.我想做一个console.WriteLine如下:

-输出:

sdkjasd; k asdkja; sdklj; asdklfj; klasdf

as; lkjas; dljk; sd; ksdlj; asd

asdlkjasd; jkas; dklj; kjsds

这些输出线分别被3条空白线隔开.我不想每条输出线写3次Console.WriteLine().我想我做了类似Console.WriteLine(Environment.NewLine ... pseudocode(3))之类的事情.如何添加3个空白 在一个Console.WriteLine(...)中排成一行?它是一种格式化功能吗?我只是不记得了.


Rich P

解决方案

Hi Rich P123,

谢谢您在这里发布.

对于您的问题,您可以将console.writeline()与"\ n"一起使用一次.指某东西的用途 环境. NewLine属性 可以获得相同的输出.

请尝试以下代码.

 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); 

这是输出.

我希望这会对您有所帮助.

如果还有其他问题,请随时与我们联系.

最好的问候,

温迪


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

解决方案

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


这篇关于在控制台中用空白行分隔输出文本行(不编写console.writeline()3次)-怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆