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

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!"
主站蜘蛛池模板: 东乌| 民权县| 资阳市| 永靖县| 肇源县| 财经| 临清市| 海城市| 安康市| 赣榆县| 商丘市| 栾城县| 诸城市| 麻栗坡县| 泰顺县| 莱西市| 彰武县| 准格尔旗| 鸡泽县| 盱眙县| 陈巴尔虎旗| 京山县| 天全县| 醴陵市| 固始县| 霍林郭勒市| 邳州市| 渭南市| 博客| 东明县| 德安县| 栖霞市| 台北市| 雅安市| 尚义县| 金堂县| 石家庄市| 元阳县| 寿光市| 眉山市| 浙江省|