-
Notifications
You must be signed in to change notification settings - Fork 0
StringBuilder extension methods
Alex Kamsteeg edited this page Aug 8, 2015
·
3 revisions
SwissArmyKnife adds the following extension methods to StringBuilder:
AppendFormatLine()
Although the StringBuilder in System.Text has a AppendFormat() and a ['AppendLine()](https://msdn.microsoft.com/en-us/library/system.text.stringbuilder.appendline(v=vs.110).aspx) method it lacks a AppendFormatLine()method to add formatted lines. This means you have to useAppendFormat()orAppendLine()` tricks to append new formatted lines:
var sb = new StringBuilder();
sb.AppendFormat("Lorem {0} dolor {1} amet {2}", "ipsum", "sit", Environment.NewLine);
// or
sb.AppendLine(string.Format("Lorem {0} dolor {1} amet", "ipsum", "sit"));With SwissArmyKnife's AppendFormatLine() you can just do the following:
var sb = new StringBuilder();
sb.AppendFormatLine("Lorem {0} dolor {1} amet", "ipsum", "sit");