What's the difference between a non-unmanaged type and a managed type?

后端 未结 2 868
自闭症患者
自闭症患者 2020-12-28 17:41

When I wrote the following snippet for experimenting purposes, it raised the hover-error (see screenshot):

Cannot declare pointer to non-unmanaged typ

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-28 18:33

    You cannot create a pointer to a managed type. While int, double, etc are managed, they have unmanaged counterparts.

    So what non-unmanaged type really means is the managed type.

    The problem here is that the managed type since is sitting on the heap, you cannot get a pointer to. You can get a pointer using fixed keyword but that is mainly for arrays.

提交回复
热议问题