Re: Compiler Error CS0702



If one regards _only_ the language, not considering .net, the CLR, CTS
etc.;
is there some reason why enum and delegate should _not_ be supported as
constraints?

Yes.

So, if you are designing a _new_ language, to write software for some
_not-yet-existent_ platform, and it includes enums and generics, you would
_not_ allow enum as a constraint for a generic? Why? That's what I want to
know.

.



Relevant Pages

  • Re: extending enum
    ... >> enum constants. ... >> superclass, plus add additional capabilities or constraints. ... casting is required when a conversion may fail ...
    (comp.lang.java.programmer)
  • Re: Compiler Error CS0702
    ... But of course that results in "Compiler Error CS0702". ... exception if the provided type is not an enum. ... And it describes the allowable constraints to clearly exclude enums or other value types. ... Well, I think the most obvious reason is that since value types can't inherit other value types, if you're constraining the class to allow only one specific value type, then there's no need for the class to be generic in the first place. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Compiler Error CS0702
    ... But of course that results in "Compiler Error ... supported as constraints? ... For example, if you write "enum ... Even more so than a generic constrained to just a single type, I don't see what the value in a generic constrained to a single value of a single type would be. ...
    (microsoft.public.dotnet.languages.csharp)
  • Compiler Error CS0702
    ... But of course that results in "Compiler Error CS0702". ... exception if the provided type is not an enum. ... Are efforts being to made to support these types as constraints? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Compiler Error CS0702
    ... And it describes the allowable constraints to clearly exclude enums or other value types. ... I don't see it anywhere on their web site. ... section 4.4.4 has to do with satistfying constraints when _using_ a generic. ... can you quote any text from the C# specification that directly leads you to believe that you should be able to specify an enum type as a constraint for a generic? ...
    (microsoft.public.dotnet.languages.csharp)