The real issue here is about rounding to integers, and enums are ints by default, so really the numbers are equivalent to:
Positivo = 0, Negativo = 1, Neutro = 1 Which would make sense by what you see printed out. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of gennady wexler Sent: Saturday, October 16, 2004 10:54 AM To: Iain McCoy; [EMAIL PROTECTED] Cc: mono Subject: Re: [Mono-list] Enum problem On 10/16/04 4:33 AM, "Iain McCoy" <[EMAIL PROTECTED]> 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? > therefore TipoCarga.Neutro == TipoCarga.Negativo. Whether this is what > css does or not I have no idea, but according to the spec it seems to > be correct (section 14.3 of the C# language specification 1.2): > "If the declaration of the enum member has a constant-expression > initializer, the value of that constant expression, implicitly > converted to the underlying type of the enum, is the associated value > of the enum member" yep I think that is correct. according to that Neg equals to Nut, since the values are the same it appears that they just get aligned differently (order wise) in code by csc and mcs. is it based on alphabetical order perhaps.. in either case, I don't see either compiler doing anything wrong case - no harm done. _______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list _______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list