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

Literals

There are a couple of minor additional capabilities and readability enhancements when specifying literal values in code. You can specify binary literals, which means you don't have to work out how to represent them using a different base anymore. You can also put underscores anywhere within a literal to make it easier to read the number. The underscores are ignored but allow you to separate digits into convention groupings. This is particularly well suited to the new binary literal as it can be very verbose, listing out all those zeros and ones.

Take the following example that uses the new 0b prefix to specify a binary literal that will be rendered as an integer in a string:

Console.WriteLine($"Binary solo! {0b0000001_00000011_000000111_00001111}");

You can do this with other bases too, such as this integer, which is formatted to use a thousands separator:

Console.WriteLine($"Over {9_000:#,0}!"); // Prints "Over 9,000!"
主站蜘蛛池模板: 谷城县| 施秉县| 汕尾市| 昭苏县| 鹤山市| 桑植县| 温州市| 兰西县| 历史| 黄龙县| 张掖市| 苏尼特左旗| 鄂尔多斯市| 岢岚县| 西峡县| 石景山区| 阳西县| 靖边县| 曲阜市| 榆树市| 祁门县| 新郑市| 鹤岗市| 垦利县| 金沙县| 无极县| 革吉县| 张北县| 富阳市| 罗甸县| 台南县| 扎鲁特旗| 宝应县| 滨海县| 霍林郭勒市| 梨树县| 铁岭县| 新宾| 亚东县| 新乡县| 卢氏县|