官术网_书友最值得收藏!

Choosing between classes and structures

Consider creating a structure when one or more of the following conditions apply:

  • The structure's primary purpose is to encapsulate a few relatively simple data values
  • It is reasonable to expect that the encapsulated values will be copied rather than referenced when you assign or pass around an instance of the structure
  • Any properties stored by the structure are themselves value types, which would also be expected to be copied rather than referenced
  • The structure does not need to inherit properties or behavior from another existing type

Examples of good candidates for structures include the following:

  • The size of a geometric shape
  • A point in a 3D coordinate system
主站蜘蛛池模板: 成武县| 阳谷县| 左贡县| 长武县| 色达县| 兴文县| 永顺县| 长泰县| 桦甸市| 二连浩特市| 云霄县| 马龙县| 双柏县| 双流县| 雷州市| 沧源| 北流市| 利辛县| 旺苍县| 西昌市| 望谟县| 曲阳县| 崇州市| 岑巩县| 油尖旺区| 贵溪市| 临沭县| 西昌市| 黔南| 兰西县| 连州市| 贡觉县| 堆龙德庆县| 望都县| 安西县| 禄劝| 静乐县| 辽宁省| 姜堰市| 英超| 财经|