Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在 CSharp 上制作的应用程序中有一个打印功能。但是我不喜欢文档的格式化方式,并且很难将文本专门格式化为打印机或类似的方式。
这是我格式化它的方式。我希望有一种更动态和更有效的方式来做到这一点,以便它可以兼容所有使用它的计算机或笔记本电脑。
您是否正在寻找已经格式化空格的东西..例如,如果我想 WriteLine(" * * HELLO * * ); 我会做这样的事情
string s = new string( '*', 8 ) WriteLine(s+ HELLO + s)
所以在你的情况下,你可以按照这个例子计算出你想要的空格数,如果你需要创建一些新的字符串变量来保存不同数量的空格,而且阅读时会更干净。这是一个简单的例子
string strSpaces = new string(' ', 20) for example..
只玩你需要的东西