Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 17th, 2007, 01:42 PM
Registered User
 
Join Date: Feb 2007
Location: Ghaziabad, UP, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to nir_pankaj
Default Two namespace contain same name

If suppose in any program there are two nameapaces referenced by using contain a type of same name as exa.--->
  say classs called namespaceclass exists both in the test.example
and welcome.example then how we should access class namespaceclass of first namespace.
test,basic

Pankaj Kumar Verma
Reply With Quote
  #2 (permalink)  
Old February 21st, 2007, 12:30 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If you have two classes of the same name in different namespaces:

  MyCompany.Project1.MyClass
  MyCompany.Project2.MyClass

And both libraries are used in some code:

using MyCompany.Project1;
using MyCompany.Project2;

...
  MyClass objInstance = new MyClass();
...

You will get an ambiguity error (i.e. the compiler doesn't know which to use).

You need to explicitly identify the class type by a fully qualified name:

  MyCompany.Project2.MyClass objInstance = new MyCompany.Project2.MyClass();


-Peter
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Namespace ~Bean~ Classic ASP Basics 2 June 3rd, 2005 02:31 PM
namespace Ibn_Aziz C# 2 December 25th, 2003 05:41 AM
namespace within namespace Bill Crawley XML 1 December 11th, 2003 10:59 AM
Namespace flute Pro VB.NET 2002/2003 2 October 21st, 2003 09:15 AM



All times are GMT -4. The time now is 05:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.