What would be the best/fastest way to sanitize strings?
Right now I wrote this function, but I don't know how efficient this really is, nor if I'm even covering all my bases:
Code:public static string Sanitize(string instr) { string ret=instr; ret=ret.Replace("\\","\\\\"); ret=ret.Replace("\"","\\\""); ret=ret.Replace("`","\\`"); ret=ret.Replace("\'","\\'"); return ret; }
Is there a better way to do this?




Reply With Quote