This documentation is archived and is not being maintained.

Conditional Methods Sample

This sample demonstrates conditional methods, which provide a powerful mechanism by which calls to methods can be included or omitted depending on whether a symbol is defined.

This sample contains the source code for the Conditional Methods Tutorial.

Building and Running the Sample Within Visual Studio

To build and run the Conditional Methods sample

  1. Open the solution (ConditionalMethods.sln).
  2. In Solution Explorer, right-click the project and click Properties.
  3. Open the Configuration Properties folder and click Debugging.
  4. Set the Command Line Arguments property to "A B C" (without the quotation marks).
  5. In the Configuration Properties folder, click Build.
  6. Modify the Conditional Compilation Constants property (for example, add or delete DEBUG) and click OK.
  7. From the Debug menu, click Start Without Debugging.

Building and Running the Sample from the Command Line

To build and run the Conditional Methods sample

  • To include the conditional method, compile and run the sample program by typing the following at the command prompt:
    csc CondMethod.cs tracetest.cs /d:DEBUG
    tracetest A B C
    

See Also

Conditional Methods Tutorial | Tutorial Samples

Show: