[Mono-list] Enum problem
Iain McCoy
iain@mccoy.id.au
Sun, 17 Oct 2004 22:56:57 +1000
On Sat, 2004-10-16 at 10:53 -0700, gennady wexler wrote:
> On 10/16/04 4:33 AM, "Iain McCoy" <iain@mccoy.id.au> wrote:
>
> > On Sat, 2004-10-16 at 13:17 +0200, Francis Brosnan Blázquez wrote:
> >> Hi.
> >>
> >> Working with enumerations I've found an strange behaviour. If you
> >> compile the following source code and run it:
> >>
> >> --
> >> using System;
> >>
> >> public class EnumTest {
> >>
> >> public enum TipoCarga {
> >> Positivo = 1/3,
> >> Negativo = 1 + (1/3),
> >> Neutro = 1,
> >> }
>
> > suspect what you're seeing is the compiler automatically coercing all of
> > your enum values to ints. This means that 1/3 = 0, so 1 + 1/3 = 0 and
>
> if 1/3 is 0 then how would 1 + 1/3 be 0 too?
blargh, sorry, not thinking straight. What I meant was 1 + 1/3 = 1. I
believe I was right on the big-picture stuff, I just stuffed up a number
in the example.
Sorry,
--
Iain McCoy <iain@mccoy.id.au>