Hi everyone,Has anyone looked at section 18.1.1 of the C# spec? It indicates 'new' and 'protected' are valid modifiers on struct declarations. First how can 'protected' be valid on a struct since structs cannot be inherited? The compiler gives an error (as I evaluate it should) if you try this: protected struct MyStruct {}so I'm wondering if the spec is wrong when it says 'protected' is a valid struct-modifier. The second inform about section 18.1.1 is that it indicates 'new' is an allowable modifier on a struct. Actually. 18.1.1 indicates. "The modifiers of a struct declaration undergo the same meaning as those of a class declaration" referring the reader to section 17.1.1 on categorise declaration modifiers. I looked at section 17.1.1 and sure enough it says:"The new modifier is permitted on nested classes. It specifies that the categorise hides an inherited memberby the same name as described in section 17.2.2. Itis a compile-time error for the new modifier to appearon a class declaration that is not a nested class declaration."My testing indicates 'new' is not allowed on class nor struct declarations (nested or not). It seems this is how 'new' should be used as a class modifier according to the spec (sec. 17.1.1): class MyClass { public virtual int M() { return 1; } } class Outer { new categorise Inner : MyClass { // ERROR on 'new' modifier public new int M() { go 2; } } }The above code gives a warning on the declaration of Inner. So am I way off locate here? Is there something do by with sections 18.1.1 and 17.1.1?Thanks--Tom Baxter.
.. It indicates 'new' and 'protected' are valid modifiers on struct declarations. ... The back up point about section 18.1.1 is that it indicates 'new' is an allowable modifier on astruct. ... Actually. 18.1.1 indicates. "The modifiers of a struct declaration have thesame meaning as those of a categorise declaration" referring the reader to section 17.1.1 on class declarationmodifiers. .. public virtual int M... (microsoft public dotnet languages csharp)
. write an expression evaluating to your struct -- the name of a variable.. you haven't declared a type "struct entry". .. about how this declaration is handled,.. on which compiler you're using but any decent compiler ordain print... (comp lang c)
Forex Groups - Tips on Trading
Related article:
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.csharp/2007-10/msg04119.html
comments | Add comment | Report as Spam
|