将“var”转换为在 Visual Studio 中显式键入?
可能的重复:
将 C# var 重构为显式类型的工具
将 Studio 是否有任何类型的快捷方式(快捷方式意味着不写出实际类型名称)允许您编写“var”并将其转换为实际类型名称?
例如
var x = new Dictionary<string, string>();
:::做魔法::
Dictionary<string, string> x = new Dictionary<string, string>();
编辑-- 对于所有讨厌这个问题的人:我问这个问题是因为我想在我的解决方案中找到对特定类型的所有引用。变量不会出现在该搜索中。
Possible Duplicate:
Tool to refactor C# var to explicit type
Does Visual Studio have any type of shortcut (shortcut meaning short of writing out the actual type name) that allows you to write "var" and have it converted to the actual type name?
ex:
var x = new Dictionary<string, string>();
::Do magic thing::
Dictionary<string, string> x = new Dictionary<string, string>();
EDIT --
To all the question haters: I asked because I was in a situation where I wanted to find all references to a particular type in my solution. Vars don't show up in that search.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Resharper 等第三方工具可以将隐式类型变量转换为显式类型变量,反之亦然。 Resharper 允许您大规模转换所有实例或选择要转换的实例。
但是,让我引导您了解使用“var”会影响性能吗?,其中提出了支持和反对隐式类型的论点。
Third party tools such as Resharper can convert implicitly typed variables to explicitly typed, and vice versa. Resharper lets you massively convert all of them or pick and choose which instances to convert.
But let me direct you to Will using 'var' affect performance?, where the arguments for and against implicitly typing are made.