Generating an indented string for a single line of text

c#, indentation, string

Solution

You can create your indention with this:

var indent = new string(' ', indentLevel * IndentSize);

`IndentSize` would be a constant with value 4 or 8.

Problem

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

Original source