471,321 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,321 software developers and data experts.

Multiple character constants in C#?

Hi,

In C++, I could create an enum like this:

enum Position
{
Quarterback = 'QB',
LeftCornerback = 'LCB',
RightOutsideLinebacker = 'ROLB'
}

The multiple character constants get packed into an integer. Up to 4
characters are put in the integer, one per nibble.

Can this be done in C#? If so, is it officially supported?

Thanks,
Mike

Feb 22 '06 #1
3 1876

<my******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi,

In C++, I could create an enum like this:

enum Position
{
Quarterback = 'QB',
LeftCornerback = 'LCB',
RightOutsideLinebacker = 'ROLB'
}

The multiple character constants get packed into an integer. Up to 4
characters are put in the integer, one per nibble.

Can this be done in C#? If so, is it officially supported?

Thanks,
Mike


Well, how do you represent a full one-byte character in a single nibble?
Would you place each ASCII character value (0-127) into the nibble? AFAIK,
without some development effort and creating your own class, you can't. At
least with enums you can't.

But that is AFAIK....

Mythran

Feb 22 '06 #2
I don't think you can do that
I C# the type Char is different than int or byte or whatever. Further more
..NET characters are unicode characters 16 bit long.
What you can do is to pack the characters by yourself and set them as
numbers.
--

Stoitcho Goutsev (100)

<my******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Hi,

In C++, I could create an enum like this:

enum Position
{
Quarterback = 'QB',
LeftCornerback = 'LCB',
RightOutsideLinebacker = 'ROLB'
}

The multiple character constants get packed into an integer. Up to 4
characters are put in the integer, one per nibble.

Can this be done in C#? If so, is it officially supported?

Thanks,
Mike

Feb 22 '06 #3
Whoops, that was a typo. Each character was in a single byte of the
32-bit integer.

Feb 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by liu | last post: by
3 posts views Thread by Maileen | last post: by
15 posts views Thread by wizardyhnr | last post: by
2 posts views Thread by Kavya | last post: by
9 posts views Thread by jraul | last post: by
10 posts views Thread by Scott Townsend | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.