T
Tem
Are these equivalent?
------------------
using System;
namespace SomeNamespace
{
}
------------------
using System;
namespace SomeNamespace
{
}
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Are these equivalent?
------------------
using System;
namespace SomeNamespace
{
}
-------------------
namespace SomeNamespace
{
using System;
}
Are these equivalent?
------------------
using System;
namespace SomeNamespace
{
}
-------------------
namespace SomeNamespace
{
using System;
}
Not quite, or at least not always.Seehttp://blogs.msdn.com/ericlippert/archive/2007/06/25/inside-or-outsid...
Jon
Brian Gideon said:Don't you have a web page of C# oddities? This would almost certainly
qualify to be listed!
I've got this one:
http://pobox.com/~skeet/csharp/teasers.html
if that's what you mean. Yes, I could add it - along with a whole bunch
I suspect I've got queued up somewhere!
--
Jon Skeet - <[email protected]>
Web site:http://www.pobox.com/~skeet
Blog:http://www.msmvps.com/jon.skeet
C# in Depth:http://csharpindepth.com
Brian Gideon said:Yep, that's the link I was referring too.

Brian Gideon said:Here's an example teaser. It demonstrates how the placement of the
using statement can create an even more peculiar effect than what the
blog elluded to. Notice how the inner placed version imports the A.B
type even though it was contained within A.C. That means it is doing
more than giving preference to a nested namespace. It must be
*walking up* the containing namespace path as well as demonstrated
below. Peculiar indeed!

Are these equivalent?
------------------
using System;
namespace SomeNamespace
{
}
-------------------
namespace SomeNamespace
{
using System;
}
Tem said:"The scope of a namespace member declared by a namespace-member-
declaration within a namespace-declaration whose fully qualified name
is N, is the namespace-body of every namespace-declaration whose fully
qualified
name is N or starts with N, followed by a period."
so which one is better? or perferred?
In that particular case, yes. But, like Jon said, it can make a
difference. I discovered this oddity and posted it in this group
quite some time ago hoping someone could point me to the section in
the specification that discusses it. I did some scouring of my own
and I believe the crucial section is 10.7 (ECMA) where it says:
"The scope of a namespace member declared by a namespace-member-
declaration within a namespace-declaration whose fully qualified name
is N, is the
namespace-body of every namespace-declaration whose fully qualified
name is N
or starts with N, followed by a period."
Clear as mud huh?
so which one is better? or perferred?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.