Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要用unsafeC# 编写一个方法,显然“不安全的构造不能在安全上下文中使用”。我去了项目属性,看到了一个允许在调试和发布版本中使用不安全代码的开关。
unsafe
但是,它不可点击。
如何为我的项目允许不安全的代码?
编辑:在文件中添加<AllowUnsafeBlocks>true</AllowUnsafeBlocks>标签PropertyGroup确实csproj可以解决问题,但我想知道是否有办法在 IDE 本身中执行此操作,因为我希望 IDE 能够执行此类操作。
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
PropertyGroup
csproj
在代码中的“不安全”关键字上使用 Alt-Enter。在那里,您将找到“允许 ethis 项目的不安全代码”选项。
不过,我不知道以后如何撤消。有趣的是,Rider 手册对此没有任何说明。