473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Namespace and Class name conflict

I have the following Namesapces (only for example, would not name them this
way in production code)
Wayne.Test.Data
Wayne.Test.BR
With in Wayne.Test.Data name space I have the following class:

public class Test
{
public Test()
{
}
}

and in Wayne.Test.BR I have the following Method:

public Test SomeMethod() <-- This fails to compile, states Test is a name
space being used as a type, but Test is only part of the namespace isn't it?
If I prefix Test with Data. then it works.

Currently we have some namespaces where this is an issue, but logically it
makes sense for us to have part of the namespace and an object in that name
space named the same. Say we have a customer object, and want to separate it
in a namespace that has all the Customer operations in it. We would do:

Company.Resources.Customer.Data <-- Data container objects, one of which
would be customer.
Company.Resources.Customer.BR <-- all the business rules for a customer.

Given that a Customer Namespace and Customer object can't co-exist, any
suggestions on how to approach this?

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute. But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein
Nov 17 '05 #1
1 3640
Hi,

I advise you not to create types with the same name that a namespace, it
brings confusion like the one you are seeing.

You can solve your case using this signature:

public Wayne.Test.Data.Test SomeMethod()
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Wayne" <Me******@community.nospam> wrote in message
news:Oi*************@TK2MSFTNGP11.phx.gbl...
I have the following Namesapces (only for example, would not name them this
way in production code)
Wayne.Test.Data
Wayne.Test.BR
With in Wayne.Test.Data name space I have the following class:

public class Test
{
public Test()
{
}
}

and in Wayne.Test.BR I have the following Method:

public Test SomeMethod() <-- This fails to compile, states Test is a name
space being used as a type, but Test is only part of the namespace isn't
it? If I prefix Test with Data. then it works.

Currently we have some namespaces where this is an issue, but logically it
makes sense for us to have part of the namespace and an object in that
name space named the same. Say we have a customer object, and want to
separate it in a namespace that has all the Customer operations in it. We
would do:

Company.Resources.Customer.Data <-- Data container objects, one of which
would be customer.
Company.Resources.Customer.BR <-- all the business rules for a customer.

Given that a Customer Namespace and Customer object can't co-exist, any
suggestions on how to approach this?

--
Thanks
Wayne Sepega
Jacksonville, Fl

Enterprise Library Configuration Console Module Generator
http://workspaces.gotdotnet.com/elccmg

"When a man sits with a pretty girl for an hour, it seems like a minute.
But
let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John | last post by:
Hi all: I am using a code from third party. I write my own part and add it to that code and compile together. I try to use "vector" in my program. So I add "#include <vector>" to my program....
8
by: James Bradley | last post by:
Hi Folks, I am coming up to speed with C# and I have run into an interesting issue. I have an old VB COM library that I need to access with a ProgId == 'xyz' I also have a C# class that is...
10
by: anders | last post by:
I have 2 external assemblies A1 and A2 that both define class X in the global namespace. I need to use both assemblies in my VB project but the names X are ambiguous. How can I get around this...
4
by: Ruslan | last post by:
Hi, I have 3 projects: 1. Common 2. Desktop
1
by: vsgdp | last post by:
I just want to clarify: Say I have a helper class that is only used in one translation file (e.g., a predicate class). I don't want the name of this class to conflict with other class names in...
6
by: Jess | last post by:
Hello, I learned that we are not allowed to add any new templates or classes or functions or anything else to std namespace. Does it mean that "std" can never be extended? I can't even add any...
3
by: CrazyJohn | last post by:
Hi guys, This is my first time posting question here, if I break any rules, please kindly point out. And I'm really glad to be a part of this community. Here is my question, Our lecturer...
4
by: Andrew | last post by:
I am having an interesting namespace conflict. When we use a third party lib we create a company assembly for any descending classes to go in. I have simplified the problem into the example...
22
by: Luna Moon | last post by:
I am reading the book "C++ Annotations", and here is a quote from the book: Namespaces can be defined without a name. Such a namespace is anonymous and it restricts the visibility of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.