Spaces in enums

  • Thread starter Thread starter Zach Corera
  • Start date Start date
Z

Zach Corera

Is there anyway to put spaces in enum values in c#?

In VB5 and VB6 you could say

[Red Car]

But that throws an error in c#
 
Hi Zech,

No, you cannot use spaces in the identifier names. white spaces (space,
tabs, new lines) are used to separate language lexemes.
I would suggest to stick with what becames a stnadrad
insead of 'Read Car' use RedCar.
 
Is there anyway to put spaces in enum values in c#?

In VB5 and VB6 you could say

[Red Car]

But that throws an error in c#

I don't think so (or at least I haven't seen it anywhere and you
couldn't in C++)

What is wrong with Red_Car?

Vin
 
Hi Vincent,

You can't. But if you want spaces in generated/serialized xml you can, using
XMLEnumAttribute.

Cheers,
Michel

Vincent Finn said:
Is there anyway to put spaces in enum values in c#?

In VB5 and VB6 you could say

[Red Car]

But that throws an error in c#

I don't think so (or at least I haven't seen it anywhere and you
couldn't in C++)

What is wrong with Red_Car?

Vin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

about enum 3
Enum TypeConverter 3
Spaces in Enum 11
Enum Extentions 7
Merge Info From Two Enums 1
same Enum and property 12
Iterate through enum of system.drawing.color 5
[Flags] Enum -- make it better 1

Back
Top