Visual Studio“如果"片段最初不会识别变量 [英] Visual Studio "if" snippet initially won't recognize variables

查看:23
本文介绍了Visual Studio“如果"片段最初不会识别变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个菜鸟问题.当我使用内置的视觉工作室if"片段时,括号中的表达式最初不会识别我班级中的任何变量.我试过谷歌但运气不佳.

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.

以下是我的重现步骤:

  1. 我输入if" - if 语句片段出现在我的智能感知中.
  2. 我按 Enter 或 Tab - 添加了 if 语句.现在括号内有一个红色框,上面写着expr".
  3. 我现在尝试开始输入我的变量 - 在智能感知窗口中没有找到任何内容.

我发现,如果我删除红色框,然后将光标移到括号外,然后再回到括号内,则智能感知将获取该变量.

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.

我的问题是:有没有更好的方法来使用带有变量的 if 代码片段?这是我的电脑吗?

My question is: Is there a better way to use the if snippet with variables? Is this my my computer?

推荐答案

感谢 Jonathon Chase 为我指明了正确的方向.这似乎是 ReSharper if 实时模板的问题.我假设有些人更喜欢那样.通过查看 JetBrains 文档,我能够让模板按照我想要的方式工作.

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:

  1. 导航到 ReSharper > 工具 > 模板资源管理器
  2. 选择 C#,然后找到 if 模板(不是 #if 模板)
  3. $expr$ 改为 $expression$

现在保存,它应该会按预期工作.

Now save and it should work as expected.

这篇关于Visual Studio“如果"片段最初不会识别变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆