1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/// <summary>
/// Adds the line numbers to text.
/// </summary>
/// <param name="text">The text.</param>
/// <returns></returns>
private string AddLineNumbersToText(string text)
{
StringBuilder sb = new StringBuilder();
string[] splitStrings = {"\r", "\r\n", "\n" };
string[] lines = text.Split(splitStrings, StringSplitOptions.None);
int lineCounter = 0;
foreach (string s in lines)
{
sb.Append(lineCounter.ToString());
sb.Append(":\t");
sb.Append(s);
sb.Append(Environment.NewLine);
lineCounter++;
}
return sb.ToString();
}
|