473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 1943

<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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Job Lot | last post by:
I have an enumeration as follows Public Enum Delimiters Tab Semicolon Comma Space End Enum How can I return character equivalent of the elements in the enumeration?
12
by: liu | last post by:
how c language to realize multiple ? can anyone tell me , thank you!
3
by: Maileen | last post by:
Hi, I would like to know how can i do if i want to display the copyright character (the C into a circle) into my About window ? thanks a lot, Maileen
11
by: Olie | last post by:
This post is realy to get some opinions on the best way of getting fast comunication between multiple applications. I have scowered the web for imformation on this subject and have just found...
15
by: wizardyhnr | last post by:
i want to try ANSI C99's unicode fuctions. so i write a test program. the function is simple, but i cannot compile it with dev c++ 4.9.9.2 under windows xp sp2, since the compiler always think that...
2
by: Kavya | last post by:
In C, the character constants are of type int but in C++ character constant are of type char. Why is there an incompatibilty here when C++ was designed to be a lot compatible to C. Shouldn't such...
9
by: jraul | last post by:
1) Am I correct that C++ does not have a defined character set? In particular, a platform might not use the ASCII character set? 2) C++ supports wchar_t types. But again, this has no defined...
10
by: Scott Townsend | last post by:
So I'm trying to Write a Backend to something and in testing I decided to create a generic front end app that can simulate the passed in Data. So I have 2 projects in my solution, though I'm...
19
by: bowlderyu | last post by:
Hello, all. If a struct contains a character strings, there are two methods to define the struct, one by character array, another by character pointer. E.g, //Program for struct includeing...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.