Re: ?? 'new' and 'protected' Modifiers on Structs ??

by Tom Baxter on 10/31/2007 4:40:00 PM How stupid of me! It's rather embarrassing, actually.

Thank you Jon, Marc and Pete. I sincerely appreciate you taking the time to
respond.

Jon, I am looking forward to your Manning book. Do you have a ballpark time
frame as to when it will be available in hard copy?





"Tom Baxter" <tlbaxter99@newsgroup.nospam> wrote in message
news:%2369iFRBHIHA.5328@TK2MSFTNGP05.phx.gbl...
>I guess I spoke too soon! :)
>
> This will compile:
>
> class A {
> protected struct B {}
> }
>
>
> but this will not:
>
> struct A {
> protected struct B {}
> }
>
>
> So, why would it be the case that a nested struct can be protected if it's
> within a class but not if it's within a struct??
>
>
>
>
>
> "Marc Gravell" <marc.gravell@gmail.com> wrote in message
> news:1193807585.887232.178660@50g2000hsm.googlegroups.com...
>> And on the "protected" side - it again relates to things that subclass
>> the containing class - i.e.
>>
>> public class BaseClass {
>> void TestBase() {
>> NestedStruct ns;
>> }
>> private struct NestedStruct { int a;}
>> }
>> public class SubClass : BaseClass {
>> void TestSub() {
>> NestedStruct ns; // **ERROR
>> }
>> }
>>
>> The above is illegal, since SubClass cannot see BaseClass.NestedStruct
>> (since it is private); however, change NestedStruct to be protected,
>> and any sublasses of BaseClass can now see it.
>>
>> Marc
>>
>
> --
> Tom Baxter

--
Tom Baxter

 

Re: ?? 'new' and 'protected' Modifiers on Structs ??

by Marc Gravell on 10/31/2007 5:14:00 PM > How stupid of me! It's rather embarrassing, actually.

Not at all; you weren't entirely sure of something, so you a: read the
spec, b: did some tests of your own to see how it behaved, and c:
asked relevant questions (with examples for illustartion) until it
"clicked". Sounds like a pretty sensible approach to me! Any other
questions, please ask away...

Marc

 

Re: ?? 'new' and 'protected' Modifiers on Structs ??

by Peter Duniho on 10/31/2007 5:32:00 PM On 2007-11-01 00:14:29 -0700, Marc Gravell <marc.gravell@gmail.com> said:

>> How stupid of me! It's rather embarrassing, actually.
>
> Not at all; you weren't entirely sure of something, so you a: read the
> spec, b: did some tests of your own to see how it behaved, and c:
> asked relevant questions (with examples for illustartion) until it
> "clicked". Sounds like a pretty sensible approach to me! Any other
> questions, please ask away...

Agreed. If only all questions posted here were approached by the
questioner so methodically and open-mindedly.

I'm always a little embarassed when I find out I read something wrong.
I suppose that's human nature. But in reality, as they say...the only
dumb question is the one you didn't ask. :) I never mind answering a
question posed by someone who is clearly sincere about the question,
and who is doing their best to present their question in an effective
way, as was the case here.

Pete

 

Re: ?? 'new' and 'protected' Modifiers on Structs ??

by Jon Skeet [C# MVP] on 11/1/2007 7:33:00 AM Tom Baxter <tlbaxter99@newsgroup.nospam> wrote:
> How stupid of me! It's rather embarrassing, actually.
>
> Thank you Jon, Marc and Pete. I sincerely appreciate you taking the time to
> respond.
>
> Jon, I am looking forward to your Manning book. Do you have a ballpark time
> frame as to when it will be available in hard copy?

March 2008 - Amazon claims the middle of March, but I suspect it'll be
the end of March instead. No doubt it will partly depend on how
speedily the last phases (indexing, proof reading etc) go.

Nice to know you're looking forward to it though :)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
 

Re: ?? 'new' and 'protected' Modifiers on Structs ??

by Jon Skeet [C# MVP] on 11/1/2007 7:34:00 AM Marc Gravell <marc.gravell@gmail.com> wrote:
> > How stupid of me! It's rather embarrassing, actually.
>
> Not at all; you weren't entirely sure of something, so you a: read the
> spec, b: did some tests of your own to see how it behaved, and c:
> asked relevant questions (with examples for illustartion) until it
> "clicked". Sounds like a pretty sensible approach to me! Any other
> questions, please ask away...

Absolutely. Frankly, anyone who asks a question referring to the spec
is streets ahead of the game in my view :)

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too