ebattulga
ebattulga

Reputation: 10991

How to convert literal string to normal string in c#

For example: mystr="\"http:\\/\\/somedomain.com\"";

i want to convert this string to "http://somedomain.com";

HttpUtility.HtmlDecode and HttpUtility.UrlDecode dont work

how can convert this?

Upvotes: 0

Views: 480

Answers (1)

turtlepick
turtlepick

Reputation: 2714

This is because you need to escape the "\" and the quotes (") character in C#. There is no Encoding / Decoding to do. If you want to get rid of the confusing backslashes add a @ before your string

myStr = @"http://www.google.com"

Nevertheless, your string looks weird so you will need to get the text inside the quotes and then remove those weirdly placed "\" in the http:// part.

Upvotes: 5

Related Questions