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

Getting ready

Remember when we used Tuples at the beginning of this chapter? Well we were using code similar to the following to get the values returned by the Tuple literal.

var (average, studentCount) = ch1.GetAverageAndCount(scores);

This was deconstructing the parts of the Tuple into the new variables average and studentCount. I do not, however, want to take a look at Tuples again. What I want to do is show how you can implement a deconstruction declaration on any type. To do this, all that we need to do is ensure that  the type has a deconstructor method. We will modify our existing Student class to add a deconstructor.

主站蜘蛛池模板: 济源市| 常州市| 都匀市| 元朗区| 全州县| 于都县| 奎屯市| 浪卡子县| 澄迈县| 台前县| 五家渠市| 邹城市| 塘沽区| 平泉县| 当雄县| 齐齐哈尔市| 福海县| 双鸭山市| 德庆县| 古浪县| 伊通| 南投市| 临汾市| 明溪县| 博白县| 汉中市| 海原县| 马边| 伊金霍洛旗| 淮阳县| 齐河县| 宜君县| 加查县| 鹤庆县| 岳阳县| 齐河县| 绥江县| 开远市| 临海市| 黎城县| 宜昌市|