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
 
Back
Top