Namespace and Class name conflict

W

Wayne

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
 
I

Ignacio Machin \( .NET/ C# MVP \)

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,
 

Ask a Question

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.

Ask a Question

Top