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

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!"
主站蜘蛛池模板: 玉树县| 花莲市| 甘南县| 晋宁县| 罗源县| 建水县| 广平县| 游戏| 密云县| 东乌珠穆沁旗| 潮安县| 蓬溪县| 新化县| 禄劝| 图木舒克市| 容城县| 呈贡县| 彰武县| 东丰县| 炉霍县| 公安县| 阿勒泰市| 平凉市| 威海市| 香港 | 奈曼旗| 陆川县| 湄潭县| 贵州省| 武鸣县| 元氏县| 西华县| 渭南市| 阿荣旗| 江西省| 长宁县| 萨迦县| 南开区| 霍州市| 岢岚县| 贡嘎县|