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

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
主站蜘蛛池模板: 怀远县| 雷山县| 甘南县| 临猗县| 福泉市| 都兰县| 霍山县| 丹阳市| 南昌县| 康乐县| 襄垣县| 临夏县| 博爱县| 洛宁县| 梅河口市| 定州市| 井陉县| 民县| 洪雅县| 巩留县| 西和县| 威远县| 岫岩| 邓州市| 栖霞市| 阳曲县| 阿拉善盟| 都昌县| 柯坪县| 谢通门县| 贵德县| 衡阳县| 交城县| 兴仁县| 武乡县| 聊城市| 宝鸡市| 吉林省| 彝良县| 乐亭县| 金门县|