C# Language Pointers & Unsafe Code Compiling Unsafe Code

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

For compiling unsafe code, you have to specify the /unsafe command-line switch with command-line compiler.

For example, to compile a program named prog1.cs containing unsafe code, from command line, give the command:

csc /unsafe prog1.cs

If you are using Visual Studio IDE then you need to enable use of unsafe code in the project properties.

enter image description here

To do this:

  • Open project properties by double clicking the properties node in the Solution Explorer.
  • Click on the Build tab.
  • Select the option "Allow unsafe code"


Got any C# Language Question?