是什么在C#不安全代码和非托管代码之间的区别? [英] What is difference between unsafe code and unmanaged code in C#?

查看:99
本文介绍了是什么在C#不安全代码和非托管代码之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是用C#不安全的代码和非托管代码之间的区别?

What is difference between unsafe code and unmanaged code in C#?

推荐答案

托管代码下的CLR的监督运行(通用语言运行时)。这是负责的事务,如内存管理和垃圾收集。

managed code runs under supervision of the CLR (Common Language Runtime). This is responsible for things like memory management and garbage collection.

所以非托管只需运行CLR的上下文之外。不安全的是那种之间托管和非托管。不安全仍然在CLR下运行,但它会让你直接通过指针访问内存。

So unmanaged simply runs outside of the context of the CLR. unsafe is kind of "in between" managed and unmanaged. unsafe still runs under the CLR, but it will let you access memory directly through pointers.

这篇关于是什么在C#不安全代码和非托管代码之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆