When editing a C# source file, I type
new {
Visual Studio auto-corrects it to
new object{
Is there a way
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. It's less typing than deleting the inserted "object".
Have you checked your auto-complete options for ReSharper? I just tried this in a new (empty) class with the default ReSharper settings and couldn't duplicate it. What version of studio/ReSharper are you using?
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#.
What are you typing before the 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.
You can configure which characters being typed commit the current intellisense selection. In Tools | Options | Text Editor | C# | IntelliSense.
Remove "{" and ensure committed by the space bar is not checked.
NB. This option is no longer present as of Visual Studio 2015.