Can structs contain fields of reference types

前端 未结 6 2096
一生所求
一生所求 2020-11-30 00:30

Can structs contain fields of reference types? And if they can is this a bad practice?

6条回答
  •  情书的邮戳
    2020-11-30 00:58

    Yes, it is possible, and yes, it is usually a bad practice.

    If you look at the .NET framework itself, you'll see virtually all structs contain primitive value types alone.

提交回复
热议问题