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

前端 未结 5 2265
走了就别回头了
走了就别回头了 2021-02-12 23:14

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

5条回答
  •  名媛妹妹
    2021-02-12 23:45

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

    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.

提交回复
热议问题