Certainly legal from the compiler's perspective. I think of enums as more of a business-rule named constant. That said, yes, 1=1, but the semantics of Value == SomeOtherValue might not be true, but only your logic surrounding these two enums can make the call on this.
Jeff Block -----Original Message----- From: Chris Stefano [mailto:[EMAIL PROTECTED] 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(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 ********************************************************************** PLEASE NOTE: The above email address has recently changed from a previous naming standard -- if this does not match your records, please update them to use this new name in future email addressed to this individual. This message and any attachments are intended for the individual or entity named above. If you are not the intended recipient, please do not forward, copy, print, use or disclose this communication to others; also please notify the sender by replying to this message, and then delete it from your system. The Timken Company ********************************************************************** =================================== 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
