Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Professional 2010: Stop "new {" from autocompleting into "new object {" (C#)

In Visual Studio Professional 2010 whenever I type the following:

new {

It automatically changes to:

new object {

Is there a way to make it not do this? "Object" does not have the properties of the object I want to anonymously create.

like image 453
knpwrs Avatar asked Aug 08 '10 02:08

knpwrs


2 Answers

https://connect.microsoft.com/VisualStudio/feedback/details/584429/autocomplete-on-new-is-interpreted-as-a-new-function-instead-of-anonymous-class

I'm pretty sure it's a bug, so I went ahead and reported it. Was going to do it sooner or later anyway :)

Hope that's okay with you.

like image 131
Rei Miyasaka Avatar answered Nov 05 '22 12:11

Rei Miyasaka


You can disable the IntelliSense completing when you type the bracket.

On the Tools menu select Options. Then, on the right hand side, expand Text Editor then C# then IntelliSense. Remove the { from the textbox under the Committed by typing the following characters:

You may also have to uncheck the Committed by pressing the space bar or get in the habit of writing new{ and relying on the auto formatting when you close the bracket (though I've never done any ASPX stuff so don't know how good the auto formatting is compared to a normal code file.)

like image 29
Samuel Avatar answered Nov 05 '22 12:11

Samuel