[Mono-list] enum broken
Paolo Molaro
lupus@ximian.com
Sun, 7 Apr 2002 12:04:38 +0200
On 04/07/02 Jonathan Stowe wrote:
> On further inspection it appears that it is something that WriteLine() is
> doing:
>
> class Test
> {
> enum Zub :int
> {
> Foo = 99,
> Bar,
> Baz
> }
>
>
> static void Main()
> {
> int foo = 0 + Zub.Foo;
> System.Console.WriteLine("Foo : {0}", foo);
>
> }
> }
>
> Works as expected. Interestingly however direct initialization of foo
Unfortunately, no. This example should not compile: it's a bug in mcs.
You can use:
int foo = (int)Zub.Foo;
to get the integer value of the enum.
> from Zub.Foo fails to compile with:
with:
int foo = Zub.Foo;
I get the correct:
tests/enum-print.cs(12) error CS0029: Cannot convert implicitly from
`Zub' to `int'
Error: Compilation failed
> (process:13688): ** WARNING **: unhandled exception
> System.FormatException: "The specified format is invalid"
Is this part of the trace where mcs calls Error()? If it died while
reporting the compilation error in your code, you might want to check
you corlib is uptodate with cvs. Error reporting works fine for me,
but if you use a mcs from cvs and the corlib from the 0.10 release
it may not work (I thinbk the format changes Gonzalo did landed in cvs
only after the release).
lupus
--
-----------------------------------------------------------------
lupus@debian.org debian/rules
lupus@ximian.com Monkeys do it better