How to Replace Those Very Stupid MS Word Curly Quotes (aka Smart Quotes)

by Erich Peterson

Want to get replace those “smart quotes” that MS Word uses in your .NET code? This will do it:

VB .NET

Dim newstr As String
newstr = oldstr.Replace(Chr(147), "& quot;") ' take out extra space b/w & and quot;
newstr = newstr.Replace(Chr(148), "& quot;") ' take out extra space b/w & and quot;

C#

string newstr;
newstr = oldstr.Replace((char)147, "& quot;") // take out extra space b/w & and quot;
newstr = newstr.Replace((char)148, "& quot;") // take out extra space b/w & and quot;