POV-Ray : Newsgroups : povray.off-topic : Lots of statistics : Re: C# WTF list Server Time
29 Jul 2024 20:21:33 EDT (-0400)
  Re: C# WTF list  
From: Invisible
Date: 15 Aug 2012 07:37:31
Message: <502b89fb@news.povray.org>
>> Enums. Urgh. An enumeration is supposed to be a type that can only take
>> on the specified set of values. Except that in C#, an enumeration can
>> take on /any/ integer value. It's just that some of these values also
>> have friendly names. *sigh*
>
> Erm... did you actually /try/ this??

Quoting Microsoft's C# language specification:

   "Each enum type has a corresponding integral type called the 
underlying type of the enum type. [...] The set of values that an enum 
type can take on is not limited by its enum members. In particular, any 
value of the underlying type of an enum can be cast to the enum type and 
is a distinct valid value of that enum type."

> Trying to assing an int to an enum variable, I get a "Cannot implicitly
> convert [...]" error for any integer value other than 0. (Don't ask me
> why they did allow it for 0 though.)

Perhaps you can't /implicitly/ convert, but try writing an /explicit/ 
cast. According to the spec, that's supposed to work.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.