📌  相关文章
📜  我什么时候应该在 c# 中使用 struct 而不是 class - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:00.701000             🧑  作者: Mango

代码示例1
Consider defining a structure instead of a class if instances
of the type are small and commonly short-lived or are commonly
embedded in other objects.

Do not define a structure unless the type has all of the following
characteristics:

• It logically represents a single value, similar to
    primitive types (integer, double, and so on).
• It has an instance size smaller than 16 bytes.
• It is immutable.
• It will not have to be boxed frequently.