Wednesday, 24 June 2015

Getting Non Escaped Double Quotes in Strings

I discovered this today by sheer chance and trying it will trying to build some dynamic Oracle scripts I was building.

Use single quotes in a StringBuilder to enclose a double quote  SingleDoubleSingle :  '"'

   StringBuilder sb = new StringBuilder();
            var col = "NameCol";
            sb.Append('"' + col + '"');
            sb.Append(" = @NAME ");

So easy when you know how!

No comments:

Post a Comment

Comments are welcome, but are moderated and may take a wee while before shown.