Connecting Tech Pros Worldwide Forums | Help | Site Map

the use of enum.

developer1996
Guest
 
Posts: n/a
#1: Nov 15 '05
Can someone please explain to me why you cannot use enum
at the method level to define a type. The declaration
seems to only work at the class level. From my
understanding enums are classified as a user define type.
I do understand that in order to define a type you have to
derive it from object or a struct. But the question still
remains why only at class level. I guess the only way to
really define a type within a class is to define an inner
class and then define an enum type within the inner class.
But the scope of the enum type would be private to the
parent class. Simple concept but I just want to know why?

Frank Oquendo
Guest
 
Posts: n/a
#2: Nov 15 '05

re: the use of enum.


Thus spake developer1996:
[color=blue]
> I guess the only way to
> really define a type within a class is to define an inner
> class and then define an enum type within the inner class.[/color]

Why not just create the enum at the namespace level?

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com


Jon Skeet
Guest
 
Posts: n/a
#3: Nov 15 '05

re: the use of enum.


developer1996 <developer1996@operamail.com> wrote:[color=blue]
> Can someone please explain to me why you cannot use enum
> at the method level to define a type.[/color]

Do you mean defining an enumeration within a method? What's the use-
case here?
[color=blue]
> The declaration
> seems to only work at the class level. From my
> understanding enums are classified as a user define type.
> I do understand that in order to define a type you have to
> derive it from object or a struct. But the question still
> remains why only at class level. I guess the only way to
> really define a type within a class is to define an inner
> class and then define an enum type within the inner class.
> But the scope of the enum type would be private to the
> parent class. Simple concept but I just want to know why?[/color]

I really don't get what you're trying to do. Could you give an example
of the kind of code you wish you could write?

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
developer1996
Guest
 
Posts: n/a
#4: Nov 15 '05

re: the use of enum.


I like to use the enumeration type for creating more
understandable and easily read code because I tend to
forget what I was doing 3 months down the road. The
enumeration type is so specific to this method it isn't
used any where else in the class nor is the enumeration
used by any other class. It would make the code appear
much clearer if I could do this. My question is not can I
do this. I realize I can't but why? This will give me a
better understanding of what is going on underneath the
covers.[color=blue]
>-----Original Message-----
>Thus spake developer1996:
>[color=green]
>> I guess the only way to
>> really define a type within a class is to define an[/color][/color]
inner[color=blue][color=green]
>> class and then define an enum type within the inner[/color][/color]
class.[color=blue]
>
>Why not just create the enum at the namespace level?
>
>--
>There are 10 kinds of people. Those who understand binary[/color]
and those who[color=blue]
>don't.
>
>http://code.acadx.com
>
>
>.
>[/color]
Closed Thread