I am not sure if you need unsafe code in that case (see answer of @mybirthname).
But when unsafe code is needed, it can be enabled in Project properties.
- In the main menu, click
Project
and then<ProjectName> properties...
- Click on the
Build
page. - Select
Allow unsafe code
.
Or one can specify /unsafe compiler option explicitly.