Why are interfaces in .Net reference types?

前端 未结 2 1473
遥遥无期
遥遥无期 2020-12-15 08:18

Why are interfaces reference types? As far as I understand, an interface is a contract between classes (or structs), so why is it a type at all? I would have thought it is n

2条回答
  •  北海茫月
    2020-12-15 09:06

    They're reference types because value types have a fixed size at compile-time, so that they can be allocated on the stack. Reference types are pointers, so the pointers are constant-size but they can point to memory of any size.

提交回复
热议问题