A query on C#

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vikrant Dogra

    A query on C#

    namespace aa
    {
    class aa
    {
    }

    is this possible in c#

    can namespace's name be same as Its one if the class's
    name?
    ..


  • Maqsood Ahmed

    #2
    Re: A query on C#

    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


    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • Christof Nordiek

      #3
      Re: A query on C#


      "Maqsood Ahmed" <maqsood_ahmed@ gawab.com> schrieb im Newsbeitrag
      news:enUDZngUFH A.3400@TK2MSFTN GP10.phx.gbl...[color=blue]
      > ....
      > 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'.
      > ....[/color]
      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


      Comment

      Working...