为单行文本生成缩进字符串 [英] Generating an indented string for a single line of text
本文介绍了为单行文本生成缩进字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从空格字符生成缩进线的最佳方法是什么.我的意思是这样的:
What is the best way to generate an indented line from space characters. I mean something similar to this:
string indent = String.Join(" ", new String[indentlevel]);
s.Write(indent + "My line of text");
推荐答案
您可以使用以下方法创建缩进:
You can create your indention with this:
var indent = new string(' ', indentLevel * IndentSize);
IndentSize
是值为4或8的常量.
IndentSize
would be a constant with value 4 or 8.
这篇关于为单行文本生成缩进字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文