Created
August 16, 2018 07:12
-
-
Save ichengzi/1dcab065ea667cd2fba29c6ec2ae5e17 to your computer and use it in GitHub Desktop.
SplitString and InsertNewLine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string InsertNewLine(string source, int len = 76) | |
{ | |
var sb = new StringBuilder(source.Length + (int)(source.Length / len) + 1); | |
var start = 0; | |
while ((start + len) < source.Length) | |
{ | |
sb.Append(source.Substring(start, len)); | |
sb.Append(Environment.NewLine); | |
start += len; | |
} | |
sb.Append(source.Substring(start)); | |
return sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment