我想在控制檯應用程序中顯示上標3。我已經嘗試了以下方法,但沒有一個能夠工作。如何在C#控制檯應用程序中顯示上標文本?
Console.WriteLine("\xB3");
(從here)
Console.WriteLine("³");
//從CHARMAP.EXE複製,也從Wikipedia
我怎麼能顯示呢?
我想在控制檯應用程序中顯示上標3。我已經嘗試了以下方法,但沒有一個能夠工作。如何在C#控制檯應用程序中顯示上標文本?
Console.WriteLine("\xB3");
(從here)
Console.WriteLine("³");
//從CHARMAP.EXE複製,也從Wikipedia
我怎麼能顯示呢?
您需要確保您的控制檯的編碼適合呈現您嘗試輸出的字符。
相關屬性爲Console.OutputEncoding
。
見MSDN: Console.OutputEncoding Property
0xB3是爲Unicode標3,所以你需要選擇UnicodeEncoding
。
它顯示爲2但不是3。'Console.WriteLine(「{0} \ xB2 = {1}」,i,i * i);'正在顯示**1²= 1 2²= 4 **但是'Console.WriteLine(「{0} \ xB3 = {1}」,i,i * i * i);'正在顯示** 13 = 1 23 = 8 ** – Spidy776
您可能想閱讀以下內容:https ://stackoverflow.com/questions/32175482/what-is-the-difference-between-using-u-and-x-while-representing-character-lite –
這也取決於終端上... –
但我已經從[這裏](https://stackoverflow.com/questions/17704169/how-to-write-superscript複製上標2在一個字符串和顯示使用messagebox顯示),它正在工作。 – Spidy776