Reputation: 127
Does anybody know how to insert "#" in a c# string variable? Is there any escape sequence for this kind of thing? for e.g.
string myString = "<li><a href="#1">Image 1</a><li>";
Upvotes: 1
Views: 127
Reputation: 127
Paddy was right. There was no need to escape [#]. I only had to escape ["]. It works fine now. Thanks Paddy and everyone else who responded.
Upvotes: -1
Reputation: 39258
string myString = "<li><a href='#1'>Image 1</a><li>";
It's better to use single quotes in attributes inside a c# string to avoid the escaping
Upvotes: 0
Reputation: 54222
Try:
string myString = "<li><a href=\"#1\">Image 1</a><li>";
You have to escape the double quotes.
Upvotes: 4