开发者

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.


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.


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.)


I've just gotten in the habit of typing "new{}". Intellisense doesn't kick in then. And since I'm always reformatting the page anyways with crtl-k;crtl-d, it spaces it out correctly later on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜