本文介紹了C# 二進制字面量的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
有沒有辦法在 C# 中編寫二進制文字,比如在十六進制前面加上 0x?0b 不起作用.
Is there a way to write binary literals in C#, like prefixing hexadecimal with 0x? 0b doesn't work.
如果沒有,有什么簡單的方法可以做到這一點?某種字符串轉換?
If not, what is an easy way to do it? Some kind of string conversion?
推薦答案
C# 7.0支持二進制文字(以及可選的下劃線數字分隔符).
C# 7.0 supports binary literals (and optional digit separators via underscore characters).
一個例子:
int myValue = 0b0010_0110_0000_0011;
您還可以在 Roslyn GitHub 頁面上找到更多信息.
You can also find more information on the Roslyn GitHub page.
這篇關于C# 二進制字面量的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!