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

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
主站蜘蛛池模板: 五大连池市| 磐石市| 运城市| 辽中县| 大厂| 班玛县| 韶山市| 丰台区| 老河口市| 抚松县| 阳春市| 门头沟区| 宝应县| 长沙市| 普宁市| 陵水| 肇东市| 三门峡市| 横峰县| 甘泉县| 长岭县| 长兴县| 公主岭市| 南城县| 胶南市| 冕宁县| 汉阴县| 凤翔县| 蓝田县| 武隆县| 内乡县| 临清市| 西林县| 温泉县| 乡城县| 汕头市| 信阳市| 象山县| 固阳县| 贵南县| 淮阳县|