-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStringHelper.cs
More file actions
36 lines (34 loc) · 935 Bytes
/
StringHelper.cs
File metadata and controls
36 lines (34 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace MetaphysicsIndustries.Ligra
{
public static class StringHelper
{
public static string PrefixLines(this string s, string prefix)
{
var sb = new StringBuilder();
foreach (var line in s.SplitLines())
{
if (!string.IsNullOrEmpty(line))
{
sb.AppendFormat("{0}{1}", prefix, line);
}
sb.AppendLine();
}
return sb.ToString();
}
public static IEnumerable<string> SplitLines(this string s)
{
using (var reader = new StringReader(s))
{
string line;
while ((line = reader.ReadLine()) != null)
{
yield return line;
}
}
}
}
}