Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show exponents under String.Format?

Tags:

html

c#

asp.net

How do I show a to the power 2 in the string.format?

analysis = String.Format("\nFormula: a^2 + b^2 = c^2");

Instead of a^2, I would like to show the same way as shown on the HTML page.

<strong>Formula: a<sup>2</sup> + b<sup>2</sup> = c<sup>2</sup></strong> 
like image 231
Amit Avatar asked Sep 05 '25 03:09

Amit


1 Answers

String.Format doesn't support converting characters to superscript. You'll need to find the correct characters yourself and pass those to String.Format.

See this answer for ways to do that.

like image 100
Pepper Paige Avatar answered Sep 07 '25 21:09

Pepper Paige