Amit
Amit

Reputation: 129

How to show exponents under String.Format?

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> 

Upvotes: 4

Views: 2086

Answers (1)

Pepper Paige
Pepper Paige

Reputation: 117

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.

Upvotes: 2

Related Questions