I need to write an unsafe
method in C# and apparently "unsafe construct cannot be used in safe context". I went to project properties and saw a switch to allow unsafe code in Debug and Release builds.
However, it is not clickable.
How do I allow unsafe code for my project?
Edit: adding <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
to PropertyGroup
tag in the csproj
file does fix the problem but I was wondering if there is a way to do this in the IDE itself, since I expect IDEs to be able to do these sort of stuff.
use Alt-Enter on the "unsafe" keyword in your code. There you will find the option to "allow unsafe code for ethis project".
I would not know how to undo thst later though. Funny that the Rider manual does not say anything about that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With