from:http://bingya.javaeye.com/blog/657978
Unsafe code may only appear if compiling with /unsafe
文章分类:.net编程
要在vs.net中使用unsafe code 我们必须在项目的属性中设置一下,设置方法如下:
点项目属性(Properties)->生成(Build)->常规(General)中:钩上允许不安全代码(Allow unsafe code)
- public static void Main(string[] args)
- {
- int i = 99, y = 200;
- unsafe
- {
- swap(&i, &y);
- }
- Console.WriteLine("x is now {0},y is now {1}",i,y);
- }
- public static unsafe void swap(int *a, int *b)
- {
- int temp;
- temp = *a;
- *a = *b;
- *b = temp;
- }
欢迎加群互相学习,共同进步。QQ群:iOS: 58099570 | Android: 330987132 | Go:217696290 | Python:336880185 | 做人要厚道,转载请注明出处!
时间: 2024-11-02 13:00:15