Enums are not boxed directly to their base (integer) type.  Casting an
instance of an enum to object boxes the enum instance.  Try this some time:
Console.Write (((object) TestEnum1.Value).GetType().FullName);

-- arlie


-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Chris Stefano
Sent: Tuesday, April 20, 2004 8:00 AM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] Is this legal? -> no compiler or runtime errors
are generated

Consider two enums



  enum TestEnum1: int

  {

    Value = 1

  }



  enum TestEnum2: int

  {

    SomeOtherValue = 1

  }





and the code



      object x = TestEnum1.Value;



      TestEnum2 y = (TestEnum2)x;



I assume that this works since the enum value is boxed and unboxed to an
int.



Any ideas?



Chris Stefano

[EMAIL PROTECTED]




--
This message has been scanned for viruses and dangerous content by Building
Intelligence, and is believed to be clean.
Please forward any queries to [EMAIL PROTECTED]


===================================
This list is hosted by DevelopMentor.  http://www.develop.com Some .NET
courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to