Re: What's the syntax for a "char" constant? How about an hex integer?
- From: "Jon Skeet [C# MVP]" <skeet@xxxxxxxxx>
- Date: 18 Nov 2005 07:05:04 -0800
Cosmin Prund wrote:
> This is supposed to be very easy, only I did not find this in MSDN so I'll
> ask here:
>
> How do I enter a char constant using the char's ASCII number? Specifically I
> want to be able to compare a char to one of CR, LF, TAB (i.e: char number
> 13, 10, 9).
The best way of doing those three is '\r', '\n' and '\t'. However, you
*can* use:
'\u000d' '\u000a' and '\u0009'
Alternatively, just:
const char CR = (char)13;
> I suppose there's a problem because c#'s char's are unicode and I'm talking
> ascii codes, but there must be a way to do it!
Fortunately all ASCII characters have the same value in Unicode.
> And while I'm at it, how do I enter a constant integer using HEX notation or
> BINARY? Again, if I wore programming Delphi I would do something like this:
> <code>
> const i = $1234;
> </code>
const int i = 0x1234;
Jon
.
- Follow-Ups:
- Re: What's the syntax for a "char" constant? How about an hex integer?
- From: Cosmin Prund
- Re: What's the syntax for a "char" constant? How about an hex integer?
- References:
- [newby] What's the syntax for a "char" constant? How about an hex integer?
- From: Cosmin Prund
- [newby] What's the syntax for a "char" constant? How about an hex integer?
- Prev by Date: [newby] What's the syntax for a "char" constant? How about an hex integer?
- Next by Date: How to convert an Access.mdb format???
- Previous by thread: [newby] What's the syntax for a "char" constant? How about an hex integer?
- Next by thread: Re: What's the syntax for a "char" constant? How about an hex integer?
- Index(es):
Relevant Pages
|