How to correctly paste HTML into C# code with Visual Studio or Resharper (or any other tool!)?
Is there any way to make a "safe开发者_如何学运维" paste into Visual Studio (C#) of HTML code? If I try to paste something like
<div class="user-info"><div class="user-action-time">answered <span title="2010-09-16 02:23:16Z" class="relativetime">21 mins ago</span>
into my code, C# will cry. Using the @ operator doesn't help us, either.
Is it possible to make a special paste in Visual Studio (2010) or Resharper?
Thanks
You can use SmartPaster Extention.
After install Right click -> Paste As... -> Paste as @String
Download links
- SmartPaster for Visual Studio 2022
- SmartPaster for Visual Studio 2019 and earlier
Use @, select pasted text and replace "
with ""
in the selection. That's what I do when I paste text containing quotes.
So none of the above worked for me! Copying a large multi-line code snippet from a web page and pasting into VS2010 always reulted in a single line with no linefeeds. The quickest work-around was to paste the HTML into MS Word and then copy this and paste it into VS2010. HTH, Matt
Have you looked at this?
http://www.clipboardfusion.com/
I don't have any personal experience, but it seems like a flexible way to perform any kind of manipulation to the clipboard you like (since you can define transforms in C#) and it's free. As noted by Alex, just doubling up on double-quotes should be fine, providing you preface the string with an '@' and this won't even need any code - just a simple string search / replace.
精彩评论