C# RichTextBox 中的摄氏度符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1536131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Celsius symbol in RichTextBox
提问by Micha? Ziober
I write windows application using C# and .NET2.0. In RichTextBox I would like to show Celsius symbol. How to do it? Is it possible?
我使用 C# 和 .NET2.0 编写 Windows 应用程序。在 RichTextBox 中,我想显示摄氏符号。怎么做?是否可以?
采纳答案by Fredrik M?rk
Do you mean Celsius symbol as in 37°C
? If so you can simply put that character where it should be, I guess:
你的意思是摄氏符号37°C
吗?如果是这样,您可以简单地将该字符放在它应该在的位置,我想:
richTextBox.Text = string.Format("{0}°C", degrees);
If you are looking for character codes (or just want to find character to copy/paste them), you can use the Character Map application in Windows (in Start -> Programs -> Accessories -> System Tools).
如果您正在查找字符代码(或只是想查找字符来复制/粘贴它们),您可以使用 Windows 中的字符映射应用程序(在开始 -> 程序 -> 附件 -> 系统工具中)。
回答by Julien Lebosquain
richTextBox1.Text = "°"
will display a degree symbol in a rich textbox but I'm pretty sure you want something else. Please rephrase your question if that's the case.
richTextBox1.Text = "°"
将在富文本框中显示度数符号,但我很确定您想要其他东西。如果是这种情况,请重新表述您的问题。
回答by Mike Two
Do you mean °C? You get ° from the keyboard as ALT + 0176 on the numeric keypad.
你的意思是°C?您从键盘上获得° 作为数字小键盘上的 ALT + 0176。
回答by Jason Kresowaty
If you are wary of embedding a non-ASCII character in your source code, you could use the following instead:
如果您担心在源代码中嵌入非 ASCII 字符,则可以使用以下代码:
richTextBox.Text = string.Format("{0}\u00B0C", degrees);
(B0
is the hexadecimal for 176
.)
(B0
是 的十六进制176
。)
回答by Elzo Valugi
° //html entity.