Last active
August 29, 2015 14:13
-
-
Save kppullin/18c6d6605b71216df5a1 to your computer and use it in GitHub Desktop.
Create multiline Java string using C# + Linqpad
This file contains 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
var s = @"SELECT * | |
FROM TABLE | |
WHERE ID = @ID | |
"; | |
var sb = new StringBuilder(); | |
var lines = Regex.Split(s, "\n"); | |
for (int i = 0; i < lines.Length; ++i) | |
{ | |
var line = lines[i]; | |
if (i == lines.Length - 1 && line.Trim().Length == 0) | |
continue; | |
sb.Append("\"" + Regex.Replace(line, "[\r\n]", "") + "\\n\" +\n"); | |
} | |
sb.Length -= 3; | |
sb.ToString().Dump(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment