This website may use cookies. More info. That's Fine x
Welcome Login

Using Visual Studio to generate new type, classes, properties, fields and methods


Generate from usage:

This feature enables you to use classes and members before you define them.

You can generate a 'stub' for any class, constructor, method, property, field, or enum that you want to use but have not yet defined.

You can generate new types and members without leaving your current location in code. This minimizes interruption to your workflow.

 

For more information, see here.

 

Eg: to generate a class called Cannon from usage.

Steps:

1. Right click on undefined class > Generate > New Type...

vs-generate1

 

 

2. Specify class, specify project etc... and click OK.  New class will be created.

vs-generate1b

 

3. New class: Cannon is generated, and is ready for use.

vs-generate1c

 

 

Eg2: to generate a property stub called ID:

Steps:

1. Right click on undefined property > Generate > Property

vs-generate2

 

2. Property stub is generated.  You can now modify the property stub to your requirements.

vs-generate3

 

 

Eg3: to generate a method stub called Shoot:

Steps:

1. Right click on undefined method > Generate > Method Stub

vs-generate4

 

2. Method stub is generated.  You can now modify the method stub to your requirements.

vs-generate5


Created on: Tuesday, July 30, 2013 by Andrew Sin