views:

66

answers:

4

What is the code-snippet or short cut to create a constructor in Visual Studio?

Visual Studio 2010 and C#.

I've used before but I can't remember.

+4  A: 

Type "ctor" and the TAB, this will create the default constructor for the class you are in

public MyClass()
{

}

On your previous question someone gave an answer where you can see all the code-snippets.

UPDATE It seems that in some cases you will have to press tab twice. Thanks @ho1.

Cesar Lopez
Minor correction, I think you need to hit `Tab` twice.
ho1
@ho1: it works if you press tab once.
Cesar Lopez
@cesar: Not for me (typing `ctor` only shows the intellisense box, then I have to type `Tab` once to close that and once to "use" the snippet), but might be some setting somewhere...
ho1
A: 

Don't know about VS 2010 but in 2008 the code snippet is 'ctor'

Mark
It is the same for vs-2008 and vs-2008, and I think is also the same for vs-2005 but not 100% sure.
Cesar Lopez
A: 

Simply type ctor then tab.

Oded
A: 

Type ctor then Press Tab Key

Real4ever