/unsafe (Enable Unsafe Mode)
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. ArchiveDisclaimer

/unsafe (Enable Unsafe Mode)



The /unsafe option allows code that uses the unsafe keyword to compile.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see Setting Visual C# Project Properties.
  2. Click the Configuration Properties folder.
  3. Click the Build property page.
  4. Modify the Allow unsafe code blocks property.

To set this compiler option programmatically

See AllowUnsafeBlocks Property.


Compile in.cs for unsafe mode:

csc /unsafe in.cs

See Also

C# Compiler Options

© 2015 Microsoft