- ASP.NET Core 2 High Performance(Second Edition)
- James Singleton
- 147字
- 2021-07-08 09:38:59
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!"
- 高手是如何做產(chǎn)品設(shè)計(jì)的(全2冊(cè))
- Java 9 Concurrency Cookbook(Second Edition)
- Python for Secret Agents:Volume II
- Git高手之路
- 從0到1:HTML+CSS快速上手
- Java Web應(yīng)用開發(fā)技術(shù)與案例教程(第2版)
- FLL+WRO樂(lè)高機(jī)器人競(jìng)賽教程:機(jī)械、巡線與PID
- Hands-On Reinforcement Learning with Python
- Hands-On Natural Language Processing with Python
- Learning OpenStack Networking(Neutron)
- 從零開始學(xué)Linux編程
- JavaScript程序設(shè)計(jì)(第2版)
- 跟戴銘學(xué)iOS編程:理順核心知識(shí)點(diǎn)
- Java程序設(shè)計(jì)教程
- JavaWeb從入門到精通(視頻實(shí)戰(zhàn)版)