[Mono-list] mcs error in switch statement?

Detlev Offenbach detlev@die-offenbachs.de
Fri, 10 May 2002 15:17:03 +0200


--------------Boundary-00=_FWCW8CRB6CESL76DC2TY
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 8bit

Hello,

I am starting to learn C# using mono. The attached example taken from 
"Programming C#" should produce a compiler error according to the book 
and several tutorials. However, mcs v0.11 doesn't produce such an error 
for the case "LiberalRepublican".

Regards
Detlev Offenbach
-- 
Detlev Offenbach
detlev@die-offenbachs.de

--------------Boundary-00=_FWCW8CRB6CESL76DC2TY
Content-Type: text/x-c++src;
  charset="us-ascii";
  name="ex3-9a.cs"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="ex3-9a.cs"

using System;

class Values {
    static void Main() {
        const int Democrat = 0;
        const int LiberalRepublican = 1;
        const int Republican = 2;
        const int Libertarian = 3;
        const int NewLeft = 4;
        const int Progressive = 5;

        int myChoice = LiberalRepublican;

        switch (myChoice) {
            case Democrat:
                Console.WriteLine("You voted Democratic.\n");
                break;
            case LiberalRepublican:     // fall through
                Console.WriteLine(
                    "Liberal Republicans vote Republican.");
            case Republican:
                Console.WriteLine("You voted Republican.\n");
                break;
            case NewLeft:
                Console.WriteLine("NewLeft is now Progressive");
                goto case Progressive;
            case Progressive:
                Console.WriteLine("You voted Progressive.\n");
                break;
            case Libertarian:
                Console.WriteLine("Libertarians are voting Republican");
                goto case Republican;
            default:
                Console.WriteLine("You did not pick a valid choices.\n");
                break;
        }
        Console.WriteLine("Thank you for voting.");
    }
}

--------------Boundary-00=_FWCW8CRB6CESL76DC2TY--