I would like for the VS compiler to raise an error when I define a string using escape literals. I am using VS 2017 .NET 4.7.
In the previous version (VS2010)
, I was getting the error
CS1009: unrecognized escape sequence.
if I defined a string like:
string foo="d:\test";
Currently, I didn't find any way to enable it. Tried to go to Project Properties > Code Analysis and open all rules, but couldn't find CS1009
at all.
The reason why I would like this behavior is that after I defined a variable as I mentioned above, I, later on, used it in a Path.Combine
method, the method that raised an exception due to illegal characters in path (tab).
I know that I can use double backslashes
for escaping the backslash
or even use @
in front of the string, but I would like in the future not to be allowed to define a string like this.
Can you please help me with this?
Thanks, George