Hmpf. ::I assume that this works since the enum value is boxed and unboxed to an int.
Wrong. It works because enums CAN be cast to their primitive type. Boxing never enters the equation here. What you ask for is legal - by design. Reference: Language specification. Thomas Tomiczek THONA Software & Consulting Ltd. (Microsoft MVP C#/.NET) (CTO PowerNodes Ltd.) > -----Original Message----- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED] On Behalf Of > Chris Stefano > Sent: Dienstag, 20. April 2004 14:00 > 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(r) 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