Reputation: 8550
I have Windows Forms UI, that allows me to enter format for string formatting in TextBox, like:
Enter result format: {sku}:{value} \n
Problem is, that \n is getting escaped, so result format string in debug view looks like:
{sku}:{value} \\n
And that produces \n instead of line break in result.
So question is, how to prevent this, or how to remove escaping before using in StringBuilder.AppendFormat()
Update: I've decided to add image from notepad++ window, may be that will help understand what I need and why (although my use case is a bit different, I think idea is the same):
Upvotes: 3
Views: 15008
Reputation: 3803
There is a general way of doing the unescaping of the string is to use regular expression
System.Text.RegularExpressions.Regex.Unescape(yourStringVariable);
How can I Unescape and Reescape strings in .net?
Upvotes: 4
Reputation: 2573
Probably, what you want to do is to use the string.Replace(@"\n", "\n") method. View more at http://msdn.microsoft.com/en-us/library/system.string.replace.aspx
Upvotes: 8