[Mono-list] enum examples from TiC# don't compile with mcs

Richard Polton Richard.Polton@morganstanley.com
Thu, 19 Dec 2002 17:24:20 +0000


Shouldn't it be

(short)Coin.Penny + (short)Coin.Nickel

??

After all, which enumerated value would represent the sum before the cast
was executed?

Just a guess,

Richard

jpo wrote:

> Hi list,
> the following example code from TiC# does not compile with mcs:
>
> using System;
>
> class EnumTest {
>     enum Coin: short {
>         Penny = 1,
>         Nickel = 5,
>         Dime   = 10,
>         Quarter = 25,
>         Dollar = 100
>     }
>
>     public static void Main ()
>     {
>         short change = (short)(Coin.Penny + Coin.Nickel);
>         Console.WriteLine (change);
>     }
> }
>
> Question: is this a bug in mcs or a bug in the book? What does csc do?
>
> Thanks in adance
>   Joerg
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list

--
This communication is intended for the addressee(s) and may contain
confidential and legally privileged information.  We do not waive
confidentiality or privilege by mistransmission.  If you have received
this communication in error, any use, dissemination, printing or copying
is strictly prohibited; please destroy all electronic and paper copies and
notify the sender immediately.