Windows Vista Beta | WinVistaBeta.com - Message | Using emdash (char(151)) in C# applications

November 20, 2008  
Subject: Using emdash (char(151)) in C# applications
Group: microsoft.public.vstudio.development,microsoft.public.vstudio.general
Date: 8/7/2008 8:21:48 AM
From: "DarrylR" [Email Address Protection]

Hello. I'm writing an application that needs to set the value of a string to
an emdash (-) (U+2014). I looked at the documentation on the Char structure
to see if I could find something that would accept the character code (e.g.
151 or hex 2014) and return the corresponding string, but I couldn't find
anything useful.

What am I missing?

Thanks,
Darryl R.



Back
Subject: Re: Using emdash (char(151)) in C# applications
Group: microsoft.public.vstudio.development,microsoft.public.vstudio.general
Date: 8/17/2008 5:16:00 AM
From: Martin Honnen [Email Address Protection]

DarrylR wrote:
> Hello. I'm writing an application that needs to set the value of a string to
> an emdash (-) (U+2014). I looked at the documentation on the Char structure
> to see if I could find something that would accept the character code (e.g.
> 151 or hex 2014) and return the corresponding string, but I couldn't find
> anything useful.

With C# you can use \u2014 in a string literal e.g.
string s = "\u2014";
Or you can use the same escape mechanism in a character literal e.g.
char c = '\u2014';
You can also cast the int value (8212 is 0x2014) to a char e.g.
char c = (char)8212;


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

Back