Delen via


How to: Generate Method Stub

Use this procedure to perform the Generate Method Stub refactoring operation. For more information, see Generate Method Stub.

Note

The appearance of features in the IDE can depend on your active settings or edition, and might differ from those described in Help. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To generate a method stub

  1. Create a console application and set it up as described in the following example. For more information, see Building Console Applications.

  2. Place the cursor on the call to CalculateArea.

  3. From the Edit menu, select IntelliSense, and then select Generate Method Stub (CTRL+K, then M).

    Or

    Click the smart tag, select Generate Method Stub

    Or

    Right-click on the cursor location, and from the context menu, choose Generate Method Stub.

IntelliSense will generate the following method stub named CalculateArea in the class named Calculator:

   internal int CalculateArea(int Length, int Width, bool IsTriangle)
   {
      throw new Exception("The method or operation is not implemented.);
   }

Example

To set up this example, create a console application, and then replace the default class named Program with the following code:

   class Calculator
   {
   }

   class Program
   {
      static void Main(string[] args)
      {
         Calculator MyCalculator = new Calculator();

         int Length = 5;
         int Width = 8;
         bool IsTriangle = false;

         int Area = MyCalculator.CalculateArea(Length, Width, IsTriangle);
      }
   }

See Also

Reference

Generate Method Stub

Other Resources

Automatic Code Generation