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

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!"
主站蜘蛛池模板: 东山县| 佛山市| 东乌珠穆沁旗| 荣成市| 呼和浩特市| 岳西县| 都江堰市| 修武县| 无极县| 安乡县| 凤庆县| 宁阳县| 玛多县| 云浮市| 绩溪县| 永寿县| 大荔县| 蓬安县| 闽清县| 灵川县| 浪卡子县| 靖安县| 辛集市| 勐海县| 林西县| 双峰县| 轮台县| 望奎县| 呼图壁县| 江源县| 卫辉市| 咸宁市| 武鸣县| 日喀则市| 靖边县| 留坝县| 扶绥县| 黑山县| 云安县| 兰西县| 玉林市|