enums

  • Thread starter Thread starter Curious
  • Start date Start date
C

Curious

Hi,

I am trying to create the following enum:

public enum myEnum {First Come First Serve, Shortest Job First, Round
Robin}

Now when I compile, errors are given. The main reason is that each
item in the enum is made of multiple words.

How can I get around this problem


Can someone help me out.
Thanks in Advance
 
you cant get around this problem. try First_Come_First_Server instead. i
think you want spaces because you want to display them to the user as it is.
rahther you can use myEnumVar.ToString().Replace("_", " ");
 
Curious said:
Hi,

I am trying to create the following enum:

public enum myEnum {First Come First Serve, Shortest Job First, Round
Robin}

Now when I compile, errors are given. The main reason is that each
item in the enum is made of multiple words.

How can I get around this problem

Combine the words:

public enum MyEnum
{
FirstComeFirstServe,
ShortestJobFirst,
RoundRobin
}

You are not allowed to space identifier names and using the above method is
pretty much common practice.
 
In addition, enums were meant to be displayed.

If you want, you could create a separate structure like an array that
contains their display name.
 
Back
Top