简体   繁体   中英

In Visual Studio with C#, how do I make the () appear automatically when I type, such as .Focus()?

In Visusal Studio 2010 Express when I type the following:

txtUsername.Fo

and then hit enter, it just creates the following with Intellisense:

txtUsername.Focus

What I want it to do it do the following:

txtUsername.Focus()

Is there a way to make Intellisense auto-add the () as the end of functions for me?

I don't think Visual Studio has this option.
Somewhat related - in some scenarios, Tab Tab will automatically insert a snippet.
for example, if + Tab Tab gives you:

if (|)
{

}
else
{

}

However, I absolutely love Resharper and completely recommend it.
It includes this functionality, in addition to all other braces ( {} , [] , <> ) and a billion other features.

JetBrains ReSharper does this for us. However it is not free, unless your project is open source.

Instead of pressing enter after starting a method that highlights in the IntelliSense drop-down, I just type in the () afterwards. That fills it in. Other keyboard strokes such as the open brace ( [ ) key, space key, period ( . ) key, the open angle bracket ( < ) and possibly a few others I either forgot or haven't yet discovered. Hope this helps.

I really like the automatic brace completion feature of the Productivity Power Tools . It doesn't add the first brace, but it does add the closing brace ( [ , " , { , ( , etc) and you can hit tab after you're done and it will take you back outside of the closing brace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM