473,473 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

enum types

I read on MSDN that enum is a ref type

http://msdn.microsoft.com/library/de...classtopic.asp
but in one of the MS publications enum is said to be a value type. (ISBN:
0-7356-1289-7 page:165)

what is enum? I am confused.

Thanks.
Dec 7 '05 #1
4 1396
Pohihihi wrote:
I read on MSDN that enum is a ref type

http://msdn.microsoft.com/library/de...classtopic.asp
but in one of the MS publications enum is said to be a value type. (ISBN:
0-7356-1289-7 page:165)

what is enum? I am confused.


Enum itself is a reference type, but the types derived from it are
value types.

(ValueType itself is a reference type too.)

Jon

Dec 7 '05 #2
so in
enum MyEnum { one, two, three }

'MyEnum' is a ref type but in

MyEnum a = MyEnum.one

'a' is a value type?


"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Pohihihi wrote:
I read on MSDN that enum is a ref type

http://msdn.microsoft.com/library/de...classtopic.asp
but in one of the MS publications enum is said to be a value type. (ISBN:
0-7356-1289-7 page:165)

what is enum? I am confused.


Enum itself is a reference type, but the types derived from it are
value types.

(ValueType itself is a reference type too.)

Jon

Dec 7 '05 #3
Pohihihi wrote:
so in
enum MyEnum { one, two, three }

'MyEnum' is a ref type but in

MyEnum a = MyEnum.one

'a' is a value type?


No, 'a' is a variable. MyEnum is a value type, but System.Enum is a
reference type.

Jon

Dec 7 '05 #4
thx.

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Pohihihi wrote:
so in
enum MyEnum { one, two, three }

'MyEnum' is a ref type but in

MyEnum a = MyEnum.one

'a' is a value type?


No, 'a' is a variable. MyEnum is a value type, but System.Enum is a
reference type.

Jon

Dec 7 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Alexander Grigoriev | last post by:
Not quite new version of GCC that I have to use, craps with the following code: enum E; enum E { e }; That is, it doesn't accept forward declaration of enum. C++ standard text doesn't...
4
by: slot | last post by:
Is it possible to compare "enum" types to basic types like "unsigned short" type at all? Thanks!
0
by: Vaclav Haisman | last post by:
Motivation: I have been working on some project recently that uses lots of enums with disjunctive intervals of values because it is rather convenient way to define series of constants with...
18
by: Nebula | last post by:
Consider enum Side {Back,Front,Top,Bottom}; enum Side a; Now, why is a = 124; legal (well it really is an integer, but still, checking could be performed..) ? Wouldn't enums be more useful if...
4
by: Nikhil Patel | last post by:
Hi all, I am a VB6 programmer and learning C#. I am currently reading a chapter on types. I have question regarding enums. Why do we need to convert enum members to the value that they represent?...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
12
by: Cmtk Software | last post by:
I'm trying to define an enum which will be used from unmanaged c++, C++/CLI managed c++ and from C#. I defined the following enum in a VS dll project set to be compiled with the /clr switch: ...
3
by: hufaunder | last post by:
Imagine you have a charting library that can draw lines, bars, floating bars, bands, etc. Lines and bars need only one input. Floating bars and bands need two inputs. There are two approaches: ...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.