How to print special character in C#?

  • Thread starter Thread starter Amuro
  • Start date Start date
A

Amuro

I want to print a string value that represent temperature.
how to print the 'little superscript circle' in C#?
thx...
 
using System;
using System.Collections;

public class MyClass
{
public static void Main()
{
Console.WriteLine("Hello, World! \u00b0");
Console.ReadLine();
}
}
 
Amuro said:
I want to print a string value that represent temperature.
how to print the 'little superscript circle' in C#?

Example:

Console.WriteLine("\x00B0");

HTH,

Michael
 
Well ALT+176 worked in some programs but not in most. You could always
copy/paste from this -> ° <- For use with °C or °F. There are also unicode
characters that are prebuilt with the degree symbol.
 
Amuro said:
I want to print a string value that represent temperature.
how to print the 'little superscript circle' in C#?

The principle is the same as for all characters: find the Unicode
character on unicode.org, and then embed it appropriately in your code
(eg using a \uxxxx escape sequence).

http://www.unicode.org/charts/charindex.html is a good starting point -
but you do need to have a reasonable idea of the name of the character.
In this case, I would search for "degree" which actually finds (at
least) 4 characters:

Degree celsius: 2103
Degree fahrenheit: 2109
Degree kelvin: 212a
Degree sign: 00b0

Of course, they may well all be represented by the same glyph.
 
Jon said:
The principle is the same as for all characters: find the Unicode
character on unicode.org, and then embed it appropriately in your code
(eg using a \uxxxx escape sequence).

Or you're starting 'charmap' and look it up in the status bar.

Best regards,

Michael
 
Degree celsius: 2103
Degree fahrenheit: 2109
Degree kelvin: 212a
Degree sign: 00b0

Except, there is no such thing as degree kelvin, just kelvin. ;) But
that's another story.
 
Morten said:
Except, there is no such thing as degree kelvin, just kelvin. ;) But
that's another story.

Yeah, right. :) Most people don't know this.

Best regards,

Michael
 
Michael Kremser said:
Yeah, right. :) Most people don't know this.

Including the folks at the Unicode Consortium, by the looks of it :)

(On the other hand, it's probably the simplest way of registering the
name so that people will find it.)
 
Jon said:
Including the folks at the Unicode Consortium, by the looks of it :)

Yes, which is questionable. You couldn't say "meter degree" or "pound
degree" as well, that'd be the same nonsense.

Best regards,

Michael
 
Back
Top