Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

/optimize (Enable/Disable Optimizations) (C# Compiler Options)

The /optimize option enables or disables optimizations performed by the compiler to make your output file smaller, faster, and more efficient.

/optimize[+ | <U>-</U>]

/optimize also tells the common language runtime to optimize code at runtime.

By default, optimizations are disabled. Specify /optimize+ to enable optimizations.

When building a module to be used by an assembly, use the same /optimize settings as those of the assembly.

/o is the short form of /optimize.

It is possible to combine the /optimize and /debug options.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Properties page.

  2. Click the Build property page.

  3. Modify the Optimize Code property.

For information on how to set this compiler option programmatically, see Optimize.

Compile t2.cs and enable compiler optimizations:

csc t2.cs /optimize

Community Additions

ADD
Show:
© 2015 Microsoft