A query on C#

  • Thread starter Thread starter Vikrant Dogra
  • Start date Start date
V

Vikrant Dogra

namespace aa
{
class aa
{
}

is this possible in c#

can namespace's name be same as Its one if the class's
name?
..
 
Hello,
Yes, A namespace can take name same as one of the classes it contains,
but you have to access this class using its fully qualified name in this
case.

Like you will have to use
aa.aa obja = new aa.aa();
to create the class's instance, even though you have used 'using'
keyword for the namespace 'aa'.

HTH, cheers.
Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net
 
Maqsood Ahmed said:
....
Like you will have to use
aa.aa obja = new aa.aa();
to create the class's instance, even though you have used 'using'
keyword for the namespace 'aa'.
....
The opposite is true:
if you have a class with the fully qualified name aa.aa and you have stated
'using aa;',
then you can use aa to reference that class but you can't use aa.aa.
The simple name aa now refers to the class aa.aa and not to the namespace
aa.
So you can't even refer to any other members of namspace aa by their fully
qualified name.

Christof
 
Back
Top