This is curious, and not covered in the C# language spec that I can find.
There appears not to be bounds checking invoked when enums are passed as
parameters. The following compiles and runs successfully. Any thoughts as
to why this would not be a language defect?

public enum E
{
   E1,
   E2
};

class Class1
{
   static void Main()
   {
      foo((E)50); // should throw runtime exception?
   }

   static void foo(E e)
   {
      System.Console.Out.WriteLine(e);
   }
}

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com
Some .NET courses you may be interested in:

NEW! Guerrilla ASP.NET, 17 May 2004, in Los Angeles
http://www.develop.com/courses/gaspdotnetls

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to