Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generate code block in C#

In eclipse there is option to generate block of commands when you press enter for example if I put the command for there is popup with for,foreach etc and when I choose for example the command foreach it generate for me for each block with the context the im in and I can change it as I like . Im using visual studio premium edition 2012 ,do I need to type all the block for every command ????

like image 314
Jean Tehhe Avatar asked Nov 23 '25 05:11

Jean Tehhe


2 Answers

The feature that you are talking about is called snippets in Visual studio environment.

Eg.

If you wanna insert a property, you do something like this:

prop and press tab twice, the IDE produces something like,

public int MyProperty {get;set;} 

leaving you to edit the just-created property by navigating (use tab key).

Something like svm and tab twice, you get a public static void main method snippet produced by the IDE.

     static void Main(string[] args)
     {

     }

For a list of all already available code-snippets, look here You can also create your own custom code snippets and use as you wish. Refer here

I asked a similar question at stackoverflow. Hope this gets you started.

like image 119
now he who must not be named. Avatar answered Nov 25 '25 19:11

now he who must not be named.


If you type 'for' and press 'TAB' twice Visual Studio will generate the code block for you.

like image 41
Carlos Machel Avatar answered Nov 25 '25 18:11

Carlos Machel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!