Scoping Usings

July 13, 2009 at 3:12 PMalex

 

Consider the following code, which results into an error when Figure class is an ambiguous reference to either N1 or N2 namespace:

using System;
using N1;
using N2;

namespace N1
{
    class Figure
    {
        public void  Method()
        {
            Console.WriteLine("N1::Figure.Method");
        }
    }
}

namespace N2
{
    class Figure
    {
        public void Method()
        {
            Console.WriteLine("N2::Figure.Method");
        }
    }
}

namespace ConsumeUsing

    class Program
    {
        static void Main(string[] args)
        {
            Figure f = new Figure(); // Error, Figure is an ambiguous reference.
            f.Method();
        }
    }
}

To resolve this, you can rewriter the using statements, and, if you want to use Figure from the namespace N2, add using N2 statement inside the ConsumeUsing scope as follows:

using System;
using N1;

namespace N1
{
    class Figure
    {
        public void  Method()
        {
            Console.WriteLine("N1::Figure.Method");
        }
    }
}

namespace N2
{
    class Figure
    {
        public void Method()
        {
            Console.WriteLine("N2::Figure.Method");
        }
    }
}

 

namespace ConsumeUsing
{
    using N2;

    class Program
    {
        static void Main(string[] args)
        {
            Figure f = new Figure(); 
            f.Method();
        }
    }
}

This will tell to compiler to, first, look at N2 classes for the candidates, then, at the outer usings.

Posted in:

Tags:

Comments (88) -

Thanks for yet an additional valuable post � much appreciated. If I could +1 rep you I would, lol.

Reply

Zune and iPod: Most people compare the Zune to the Touch, but after seeing how slim and surprisingly small and light it is, I consider it to be a rather unique hybrid that combines qualities of both the Touch and the Nano. It's very colorful and lovely OLED screen is slightly smaller than the touch screen, but the player itself feels quite a bit smaller and lighter. It weighs about 2/3 as much, and is noticeably smaller in width and height, while being just a hair thicker.

Reply

That�s truly quite practical for what I�m glimpse at now, thank you a bunch.

Reply

Its a very good post, i had subscribed your post.Please update the latest information.  

Reply

Some men worship rank, some worship heroes, some worship power, some worship God, and over these ideals they dispute, but they all worship money.

Reply

Awesome post, hey I came across this post while searching for lyrics. Thanks for sharing I'll email my friends about this too.

Reply

This is so great that I had to comment. I'm usually just a lurker, taking in knowledge and nodding my head in quiet approval at the good stuff.....this required written props. Theory rocks...thanks.

Reply

Your post really made me think, have you any further reading you would recommend?

Reply

do you have an rss feed? I want to add it to my reader but I can't find it...

Reply

how can I advertise on your blog?

Reply

you may make some money if you add an affiliate program to your blog...

Reply

great blog! I too have one ob dating and seduction tips for guys...

Reply

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post

Reply

it will be great if you post more...

Reply

don't forgot to get out and exercise...

Reply

try to change your template, there are some great ones...

Reply

any plan to update this blog?

Reply

do you have a xml feed for your blog?

Reply

how old is this post?

Reply

nice blog but it deserve a better theme...

Reply

you have a great blog! Thanks for the info!

Reply

Thank you for your info. It has been an ideal read. This is just what I'm interested in... Thank you for posting.

Reply

You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

Reply

I should really be working

Reply

We are a group of volunteers and starting a new initiative in a community. Your blog provided us valuable information to work on.You have done a marvellous job!

Reply

Oh was het een wedstrijd? Echt raar dat wij meteen daarnaast stonden op te treden, haha

Reply

gehen die Uhren anders Smile | Jedem Völkchen sein Pläsierchen - die oberbayr. Uhren ticken ja auch individuell Smile

Reply

Pretty insightful post. Never thought that it was this simple after all. I had spent a good deal of my time looking for someone to explain this subject clearly and you’re the only one that ever did that. Kudos to you! Keep it up

Reply

Great nightime reading thankyou.

Reply

We are a small band of volunteers and getting into a brand new related blog. Your site offered us all pertinent info to work upon.You have done a outstanding work!

Reply

Hey, great blog...I'll add your site in my rss reader, if I can figure out how to get it to work...LOL

Reply


I am so much impressed with the initiative taken by you all... !! Keep it up !!

Reply


This looks crazy. Haven't ever thought upon this. This is reckoning man.. !!
Well I was looking for some concrete information here ..
great help to others ! Keep helping.

Reply

I differ with most folks here; since I found this blog post I couldn't stop until , while it wasn't just what I had been looking for, was a nice read though. I will immediately take your RSS feed to stay informed of any updates.

Reply

Hey, maybe I will be some how off topic here, however I had been reading your site and it appears outstanding!. I’m building a blog and attempting to make it interesting, however each time I touch it I screw something up. Did you design and style the website by yourself? Can somebody with very little experience do it, as well as add updates without messing it up? well, great information on here, very helpful.

Reply

This is a great point there. I made a investigation on the topic and found most people will agree with your blog.  Well I'll be subscribing to your feed and I wish you post again soon.

Reply

Sources like the one you mentioned here will be very helpful to me! I will link to this blog on my site. Thank you for posting that link, however, it appears to be broken.

Reply

Nice site, just gave it a link on reddit.com

Reply

I don’t agree with most people here; since I found this post I couldn't stop until I finished, while it wasn't just what I had been trying to find, was still a fantastic read though. I will immediately take your feed to maintain informed of future updates.

Reply

In point of fact, I’m just beginning in marketing media and trying to find out how to do it well - resources like this blog post are very helpful. As our website is based in the US, is kind of new to us The reference mention is something that I worry about as well, how to show your own genuine enthusiasm and contribute to the solution.

Reply

Hey, probably I am being a little bit off topic here, however I had been reading your website and it looks outstanding!. I’m creating a blog and attempting to make it interesting, however everytime I touch it I wreck something up. Did you design and style the website by yourself? Can a person with very little knowleadge do it, as well as add updates without messing it up? Anyway, great information on here, extremely helpful.

Reply

Totally new to me; I wasn't aware of the many ramifications and depth to this story until I surfed here through Google! Fantastic job.

Reply

Many thanks for making the truthful effort to explain this. I feel fairly strong about it and would like to nkwo more. If it's OK, as you learn more in depth knowledge, would you mind posting more articles similar to this one with more information?

Reply

That’s a very good point there. I made a investigation on the topic and found many people will agree with your article.  Well I’ll subscribe to your feed and I hope you post again soon.

Reply

You made a very good point right there. I made a search on the topic and found most people will agree with your article.  Well I'll be subscribing to your feed and I wish you post again soon.

Reply

Sources like the one you just mentioned here will be very helpful to me! I will post a link to this site on my site. Thanks for dropping that link, nonetheless, it seems to be broken.

Reply

I disagree with most guys here; I started reading this post I couldn't stop until ,  even though it wasn't just what I had been searching for, was still a very good read though. I will instantly get your RSS feed to maintain in touch of future updates.

Reply

Hi, probably I am being a little bit off topic here, however I had been checking your website and it looks great!. I’m building a web site and attempting to make it appear clean, however every single time I touch it I wreck something up. Did you build and style the blogsite by yourself? Can a person with very little knowleadge do it, as well as add updates without messing it up? Anyway, great information on here, extremely helpful.

Reply

That's news to me; I didn’t know the many ripples and depth to the case until I searched here through Bing! Fantastic job.

Reply

Thanks for making the truthful effort to explain this. I feel fairly strong about this and would like to nkwo more. If you can, as you find out more in depth knowledge, would you mind writing more articles similar to this one with more tips?

Reply

I don’t agree with most guys here; since I found this post I couldn't stop until I finished, although it wasn't just what I had been searching for, was still a very good read though. I will instantly get your feed to maintain in touch of coming updates.

Reply

In fact, I’m just starting out in management media and working on to find out how to do it well - resources like this article are very helpful. As our Site is based in the US, it’s all a bit new to us. The case mention is something that I worry too well, how to show your own authentic enthusiasm and contribute to the opportunity.

Reply

Many thanks for making a sincere effort to explain this. I feel fairly strong about it and would like to nkwo more. If it's OK, as you learn more in depth knowledge, would you mind posting more posts similar to this one with more tips?

Reply

She is just fantastic! Everything she touches converts to gold, so in spite of some gossips or fabrications about her, she continues on the top. Way to go girl, the sky is your limit.

Reply

I differ with most guys here; I found this post I couldn't stop until I was done, while it wasn't just what I had been searching for, was a fantastic read though. I will immediately take your feed to maintain informed of future updates.

Reply

In fact, I’m just starting out in management media and trying to learn how to do it well - resources like this blog post are a great resource. As our website is based in the US, it’s all a bit new to us. The reference mention is something that I worry about as well, how to show your own real enthusiasm and contribute to the opportunity.

Reply

Hey, probably this is a little bit off topic here, however I had been reading your blog and it appears outstanding!. I’m creating a blog and attempting to make it appear clean, however everytime I touch it I screw something up. Did you build and style the blogsite by yourself? Can somebody with very little knowleadge do it, as well as add frequent updates without messing it up? well, info on here, extremely helpful.

Reply

All new to me; I didn’t know the many ripples and depth to this case until I searched here through Bing! Great job.

Reply

Thanks for making a truthful effort to explain this. I feel very strong about it and would like to nkwo more. If it's OK, as you learn more in depth knowledge, would you mind writing more posts similar to this one with more tips?

Reply

This is a great point right there. I made a research on the topic and found most people will agree with your article. Any way I’ll subscribe to your feed and I hope you post again soon.

Reply

Resources like the one you just mentioned here will be very useful to me! I will link to this page on my site. Thank you for posting that link, nevertheless, it seems to be down.

Reply

She is just wonderful! Everything she touches it turns to gold, so regardless of some chitchats or lies about her, she keeps on the top. So go girl, the sky is your limit.

Reply

I disagree with most guys here; I found this blog post I couldn't stop until I was done,  even though it wasn't just what I had been looking for, was indeed a great read though. I will immediately grab your blog feed to keep informed of coming updates.

Reply

Actually, I’m just getting my feet wet in management media and starting to find out how to do it well - resources like this article are incredibly helpful. As our company is based in the US, it’s all a bit new to us. The case above is something that I worry too well, how to show your own genuine enthusiasm and contribute to the solution.

Reply

She is just wonderful! All she touches it turns to gold, so despite some rumors or fabrications about her, she remains on the top. Way to go girl, we love you

Reply

I differ with most people here; I started reading this post I couldn't stop until I finished, although it wasn't just what I had been looking for, was still a nice read though. I will instantaneously take your blog feed to stay informed of any updates.

Reply

In fact, I’m just starting out in community management/marketing media and starting to learn how to do it well - resources like this blog post are very helpful. As our company is based in the US, is kind of new to us The reference above is something that I worry about as well, how to show your own real enthusiasm and share to the community.

Reply

I read your article.The things you have written sound very sincere and nice topics i am looking forward to its  continuation. Many of us don't know about this event. Your post is helpful.

Reply

She is just wonderful! All she touches converts to gold, so no matter some rumors or fabrications about her, she continues on the top. Way to go girl, you're the best

Reply

I admire the valuable information you offer in your articles. I'm very excited and longing for your next article. Hopefully I will get it this week. Really value this post especially. It's hard to separate the very good from the bad these days, but I believe you've pushed the right key! Is it possible to write a guest articles here? I would like to write a one or two articles here.

Reply

Totally new to me; I didn’t know the many ripples and depth to this case until I surfed here through Yahoo! Good job.

Reply

I think helpful site. Thanks for sharing it with me!

Reply

Thank you for making the sincere effort to explain this. I feel very strong about this and would like to nkwo more. If it's OK, as you find out more in depth knowledge, would you mind posting more articles similar to this one with more information?

Reply

I disagree with most folks here; I found this post I couldn't stop until ,  even though it wasn't just what I had been searching for, was indeed a fantastic read though. I will instantly grab your RSS feed to maintain in touch of any updates.

Reply

In point of fact, I’m just starting out in community management/marketing media and starting to learn how to do it well - resources like this blog post are very helpful. As our company is based in the US, it’s all a bit new to us. The case mention is something that I worry too well, how to show your own real enthusiasm and contribute to the opportunity.

Reply

Faith indeed tells what the senses do not tell, but not the contrary of what they see. It is above them and not contrary to them.

Reply

A awesome site. I will visit again soon!

Reply

She is just wonderful! All she touches it turns to gold, so no matter some gossips or fabrications about her, she remains on the top. Way to go girl, the sky is your limit.

Reply

Endeavor to be always patient of the faults and imperfections of others for thou has many faults and imperfections of thine own that require forbearance. If thou are not able to make thyself that which thou wishest, how canst thou expect to mold another in conformity to thy will   -   Thomas a Kempis

Reply

I don’t agree with most people here; since I found this blog post I couldn't stop until ,  even though it wasn't just what I had been looking for, was indeed a great read though. I will instantly take your feed to maintain in touch of future updates.

Reply

In fact, I’m just beginning in management media and working on to learn how to do it well - resources like this blog are a great resource. As our Site is based in the US, is kind of new to us The example above is something that I worry too well, how to show your own genuine enthusiasm and share to the solution.

Reply

Actually, I’m just starting out in marketing media and trying to find out how to do it well - resources like this article are a great resource. As our company is based in the US, it’s all a bit new to us. The reference above is something that I worry about as well, how to show your own real enthusiasm and share to the fact.

Reply

Actually, I’m just beginning in management media and trying to learn how to do it well - resources like this blog post are very helpful. As our company is based in the US, is kind of new to us The case above is something that I worry about as well, how to show your own authentic enthusiasm and contribute to the fact.

Reply

This was a really good post. I visit here evaryday.

Reply

This was a really cute info. Nice design.

Reply

Its very good article. Check out my blog too.

Reply

That's news to me; I didn’t know the many ramifications and depth to this story until I surfed here through Google! Fantastic job.

Reply

Tyson F. Gautreaux
United States Tyson F. Gautreaux says:

If you're still on the fence: grab your favorite earphones, head down to a Best Buy and ask to plug them into a Zune then an iPod and see which one sounds better to you, and which interface makes you smile more. Then you'll know which is right for you.

Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading