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

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
主站蜘蛛池模板: 吉木萨尔县| 巫山县| 大化| 汶川县| 龙陵县| 罗平县| 喜德县| 青浦区| 辛集市| 镇安县| 集贤县| 凤山市| 库尔勒市| 龙南县| 宁乡县| 仁布县| 侯马市| 清河县| 苍溪县| 凤凰县| 邵武市| 项城市| 马关县| 旌德县| 凭祥市| 建湖县| 高要市| 夏津县| 漾濞| 高密市| 安化县| 石泉县| 梅河口市| 全州县| 和林格尔县| 揭阳市| 兴安盟| 偏关县| 汉川市| 泗阳县| 仙游县|