简体   繁体   English

当我输入“new {”时,如何阻止Visual Studio插入“object”

[英]How do I stop Visual Studio from inserting “object” when I type “new {”

When editing a C# source file, I type 编辑C#源文件时,我输入

new {

Visual Studio auto-corrects it to Visual Studio自动更正它

new object{

Is there a way to stop this behavior? 有没有办法阻止这种行为?

You can configure which characters being typed commit the current intellisense selection. 您可以配置要键入的字符提交当前智能感知选择。 In Tools | 在工具| Options | 选项| Text Editor | 文字编辑器| C# | C#| IntelliSense. 智能感知。

Remove "{" and ensure committed by the space bar is not checked. 删除“{”并确保未选中空格键提交的内容。

NB. NB。 This option is no longer present as of Visual Studio 2015. 从Visual Studio 2015开始,此选项不再存在。

I ran into this issue, and the answers above didn't work for me. 我遇到了这个问题,上面的答案对我不起作用。 In my case, it was caused by Resharper, and I addressed it by navigating to Resharper -> Options -> Environment -> Intellisense -> Completing Characters and adding the opening curly brace character "{" to the "Do not complete on" list for C#. 在我的情况下,它是由Resharper引起的,我通过导航到Resharper - >选项 - >环境 - >智能感知 - >完成字符并将开头大括号字符“{”添加到“不完整”列表来解决它对于C#。

What are you typing before the new { ? 你在new {之前打字的是什么?

I've just tried it and it auto-completes with the object type, so if I type: 我刚刚尝试过它,它会自动完成对象类型,所以如果我输入:

Button test = new { 

it becomes: 它成为了:

Button test = new Button{

But if I type: 但如果我输入:

var test = new {

it leaves it alone. 它让它独自一人。

I haven't configured my VS2008 install in any way. 我没有以任何方式配置我的VS2008安装。

Have you checked your auto-complete options for ReSharper? 你有没有检查过ReSharper的自动完成选项? I just tried this in a new (empty) class with the default ReSharper settings and couldn't duplicate it. 我刚刚使用默认的ReSharper设置在一个新的(空)类中尝试了这个,并且无法复制它。 What version of studio/ReSharper are you using? 您使用的是什么版本的studio / ReSharper?

Try typing the left brace first, then going back and typing new. 尝试先键入左括号,然后返回并键入新的。 VS2008 does this for me (without ReSharper) and, if I remember, this is what I do. VS2008为我做了这个(没有ReSharper),如果我记得的话,这就是我的工作。 It's less typing than deleting the inserted "object". 它比删除插入的“对象”更少打字。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何阻止 Visual Studio 2017 在保存时构建 - How do i stop visual studio 2017 from building on save 通过FTP连接时如何停止Visual Studio 2010下载大文件 - How do I stop Visual Studio 2010 from downloading large files when connected through FTP 当我使用Designer向表单添加新控件时,如何阻止visual studio更改WPF表单中控件的属性? - How to stop visual studio from changing properties of controls in WPF form when I add a new control to form using Designer? 如何让我的控制台窗口停止让我在Visual Studio中输入? - How do I make my console window stop making me type enter in Visual Studio? 每次打开窗体时,如何阻止Visual Studio放大控件? - How do I stop Visual Studio from enlarging controls every time I open a windows form? 当我已经吞下异常时,如何阻止 Visual Studio 中断异常? - How can I stop Visual Studio from breaking on Exceptions when I have already swallowed them? 如何在Visual Studio 2010中停止自动轮廓扩展? - How do I stop Auto Outline Expansion in Visual Studio 2010? 如何在Visual Studio中更改文本框的制表位长度? - How do I change the tab stop length for a textbox in visual studio? 如何在Visual Studio 2015输出窗口中阻止C#编译器输出? - How do I stop the C# compiler output from wrapping in the Visual Studio 2015 output window? 如何阻止Visual Studio在UserControl中生成Setter调用? - How Do I Stop Visual Studio from Generating Setter Calls in my UserControl?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM