开发者

how to remove character escaping from a string in C#

开发者 https://www.devze.com 2023-01-28 01:55 出处:网络
I have some code that takes input from and excel spreadsheet and imports it into a SQL Server database. I am having some trouble dealing with strings that have double quotes in them.

I have some code that takes input from and excel spreadsheet and imports it into a SQL Server database. I am having some trouble dealing with strings that have double quotes in them. Here is what happens: A cell has this text in it -> pipe 3/8"

When I bring that text into the C# string ob开发者_如何转开发ject, the value looks like this: pipe 3/8\"

So, when I attempt to query SQL, to look for this item, it searches for 3/8\" which id does not find.

How can I output the string from the C# string object so that it does not have the escape characters in it?

Thanks.


the value looks like this: pipe 3/8\"

But only in the debugger. Show it somewhere and the \ will be gone.


In SQL your string should be 3/8" again. The escape character \ will only exist while the string is loaded in C#.

0

精彩评论

暂无评论...
验证码 换一张
取 消