public static string NumberLines(string s) { if (s == null) { throw new ArgumentNullException("s"); } StringReader stringReader = new StringReader(s); StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture); int num = 1; StringUtils.ActionTextReaderLine(stringReader, stringWriter, (TextWriter tw, string line) => { tw.Write(num.ToString(CultureInfo.InvariantCulture).PadLeft(4)); tw.Write(". "); tw.Write(line); num++; }); return(stringWriter.ToString()); }
public static string Indent(string s, int indentation, char indentChar) { if (s == null) { throw new ArgumentNullException("s"); } if (indentation <= 0) { throw new ArgumentException("Must be greater than zero.", "indentation"); } StringReader stringReader = new StringReader(s); StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture); StringUtils.ActionTextReaderLine(stringReader, stringWriter, (TextWriter tw, string line) => { tw.Write(new string(indentChar, indentation)); tw.Write(line); }); return(stringWriter.ToString()); }
public static string NumberLines(string s) { if (s == null) { throw new ArgumentNullException("s"); } StringReader textReader = new StringReader(s); StringWriter stringWriter = new StringWriter(CultureInfo.get_InvariantCulture()); int lineNumber = 1; StringUtils.ActionTextReaderLine(textReader, stringWriter, delegate(TextWriter tw, string line) { tw.Write(lineNumber.ToString(CultureInfo.get_InvariantCulture()).PadLeft(4)); tw.Write(". "); tw.Write(line); lineNumber++; }); return(stringWriter.ToString()); }