Better way to write a string slicer Here is some code to insert a new line escape sequence after a certain number of characters (for fixed width displays)

    private string spliceNoteText(string text)
    {
        StringBuilder sb = new StringBuilder();

        int maxWidth = 70;
        int blockOfText;

        for (int i = 0; i &lt;= text.Length; i += maxWidth)
        {
            if (i &gt;= text.Length)
                continue;

            int charsRemaining = text.Length - i;

            if (charsRemaining &lt;= maxWidth)
                blockOfText = charsRemaining;
            else
                blockOfText = maxWidth;

            sb.Append(text.Substring(i, blockOfText));
            sb.Append("\n");

        }
        return sb.ToString();
    }


It's is ugly and boring, can it be made prettier or more elegant?
You could already create the StringBuilder with the text you want to 'splice', rather than building it up again. Then you can just determine how many newline characters you want to add (and you should use Environment.NewLine instead of specifying it explicitly), and insert them in the right place.

    private string SpliceNoteText(string text, int maxWidth)
    {
        StringBuilder sb = new StringBuilder(text);

        for (int i = 0; i &lt; (sb.Length / maxWidth); i++)
        {
            int insertPosition = i * maxWidth;
            sb.Insert(insertPosition, Environment.NewLine);
        }

        return sb.ToString();
    }