Compiler Error CS0227
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

Compiler Error CS0227

Updated: August 2008

Unsafe code may only appear if compiling with /unsafe

If source code contains the unsafe keyword, then the /unsafe compiler option must also be used. For more information, see Unsafe Code and Pointers (C# Programming Guide).

To set the unsafe option in Visual Studio 2008, click on Project in the main menu, select the Build pane, and check the box that says "allow unsafe code."

The following sample, when compiled without /unsafe, will generate CS0227:

// CS0227.cs
public class MyClass
   unsafe public static void Main()   // CS0227




August 2008

Added information on how to set the unsafe option in Visual Studio.

Customer feedback.

© 2016 Microsoft