是否可以用特殊的方式写10 ^ 2? [英] Is it possible write 10^2 in a special way?

查看:70
本文介绍了是否可以用特殊的方式写10 ^ 2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在C#中编写10²10³?

Is it possible to write 10² or 10³ in C#?

例如在标签或控制台输出中.

For example in a label or Console output.

我还想将其用于其他功能(10 4 ,10 5 ,...).

I also want use it for other powers (104, 105, ...).

类似的东西:

string specialNumber = string.Format("10^4");
System.Console.Write(specialNumber);

推荐答案

这实际上是两个不同的问题.一个用于控制台,另一个用于GUI应用程序.我选择遮盖控制台.

This is really two different questions. One for the console, and one for a GUI app. I'm choosing to cover the console.

如果只需要2号和3号电源,则可以执行以下操作:

If you just need powers 2 and 3 you can do this:

Console.WriteLine("10²");
Console.WriteLine("10³");

这使用了字符 U + 00B2 U + 00B3 .

如果事实证明您需要不同的电源,那么您在控制台上就不走运了.虽然有用于其他数字的Unicode字符,但字体支持很差,使用以下代码将无法成功:

If it turns out that you require different powers then you are out of luck at the console. Whilst there are Unicode characters for other numerals, font support is poor and you will have no success with code like this:

Console.WriteLine("10⁴");
Console.WriteLine("10⁵");
Console.WriteLine("10⁶");
// etc.

许多常用的控制台字体不包含这些字符的上标字形.例如,这就是使用Consolas在我的机器上的样子:

Many commonly used console fonts do not include superscript glyphs for these characters. For example, this is what it looks like on my machine using Consolas:

如果使用的是Lucinda Console的默认控制台字体,则结果是相同的.

If you are using the default console font of Lucinda Console, then the results are the same.

这篇关于是否可以用特殊的方式写10 ^ 2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆