Reputation: 45145
String interpolation is great and snippets are great, but they don't play nice together. I have a snippet that looks (in part) like this:
job.Location = $"{e["$locationfield$"]}";
return true;
The locationfield
part is supposed to be the replacement, but of course it will see as '"{e["
being a replacement. So when you try to use the snippet, that part is messed up:
job.Location = locationfield
And the rest of the code following is gone (because it can't match another $
presumably).
Is there a way around that? Or can you just not use string interpolation in your snippets?
Upvotes: 8
Views: 699
Reputation: 45145
Ok, as it turns out, it's dead simple. I did this on a whim and it worked:
job.Location = $$"{e["$locationfield$"]}";
return true;
Another solution that I didn't try, is that you can actually specify what the snippet should use as a delimiter:
<Code Language="csharp" Delimiter="$">
Just change the $
to something else you aren't using in this particular block of code.
Upvotes: 8