本文介绍了不安全代码有什么错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
错误1只有在使用/unsafe C:\ Visual Studio 2010 \ Projects \ Unsafe \ Unsafe \ Program.cs进行编译时,才会出现不安全代码6 24不安全 错误2只有在使用/unsafe C:\ Visual Studio 2010 \ Projects \ Unsafe \ Unsafe \ Program.cs进行编译时,才会出现不安全代码10 31不安全
Error 1 Unsafe code may only appear if compiling with /unsafe C:\Visual Studio 2010\Projects\Unsafe\Unsafe\Program.cs 6 24 Unsafe Error 2 Unsafe code may only appear if compiling with /unsafe C:\Visual Studio 2010\Projects\Unsafe\Unsafe\Program.cs 10 31 Unsafe
using System; class Unsafe { unsafe static void SquarePtrParam(int *p) { *p *= *p; } unsafe public static void Main(string[] args) { int i = 5; SquarePtrParam(&i); Console.WriteLine(i); } }[删除电子邮件]谢谢.
[EMAIL REMOVED] Thanks.
推荐答案您需要在Visual Studio的编译选项中添加"/unsafe"开关. You need to add "/unsafe" switch in the compiling options in visual studio.
选择项目属性.在构建"标签中,选中复选框 允许不安全的代码".生成应用程序并运行文件. 问候, Vineeth Select the project properties. In ''Build'' tab check the checkbox ''Allow unsafe code''.Build the application and run the file. Regards, Vineeth
仍然允许不安全代码"仍然错误程序"C:\ *"不包含适用于入口点的静态"Main"方法-谢谢 ''Allow unsafe code" still error Program "C:\*" does not contain a static "Main" method suitable for an entry point - Help me, THANKS
更多推荐
不安全代码有什么错误?
发布评论