问题
I have a noob question. When I use the built in visual studio "if" snippet the expression in the parentheses won't initially recognize any of the variables in my class. I have tried google without much luck.
Here are my steps to reproduce:
- I type "if" - the if statement snippet appears in my intellisense.
- I hit enter or tab - the if statement is added. There is now a red box inside the parentheses that says "expr".
- I now attempt to start typing my variable - nothing is found in the intellisense window.
I have found that if I delete the red box and then move the cursor outside of the parentheses then go back inside the parentheses, the intellisense will then pick up the variable.
My question is: Is there a better way to use the if snippet with variables? Is this my my computer?
回答1:
Thanks Jonathon Chase for pointing me in the right direction. This seems to be an issue with the ReSharper if
live template. I would assume some folks like it better that way. Looking through the JetBrains documentation I was able to make the template work the way I wanted.
Here's what I did to fix this issue:
- Navigate to ReSharper > Tools > Templates Explorer
- Select C# and then find the if template (not the #if template)
- Change
$expr$
to$expression$
Now save and it should work as expected.
来源:https://stackoverflow.com/questions/53528946/visual-studio-if-snippet-initially-wont-recognize-variables