question about inheritance and Imports statement

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

    question about inheritance and Imports statement

    Does a subclass have to import namespaces which were already imported by the
    superclass?

    I have a base class which imports the System.Data.SQL Client namespace to use
    the dataset member.

    When I inherit this base class, the subclass must also import the
    System.Data.SQL Client namespace to use its members.

    I thought that a subclass would not have to re-import namespaces which were
    already imported by the superclass.

    Do I understand correctly, or am I doing something wrong?

    Thanks
    Bill


  • Robinson

    #2
    Re: question about inheritance and Imports statement

    If you go to your project properties -References, you can import the
    reference for the entire project, rather than doing it on a file by file
    basis.

    "BillE" <belgie@datamti .comwrote in message
    news:eFPeOBNCHH A.2328@TK2MSFTN GP02.phx.gbl...
    Does a subclass have to import namespaces which were already imported by
    the superclass?
    >
    I have a base class which imports the System.Data.SQL Client namespace to
    use the dataset member.
    >
    When I inherit this base class, the subclass must also import the
    System.Data.SQL Client namespace to use its members.
    >
    I thought that a subclass would not have to re-import namespaces which
    were already imported by the superclass.
    >
    Do I understand correctly, or am I doing something wrong?
    >
    Thanks
    Bill
    >
    >

    Comment

    • Chris Dunaway

      #3
      Re: question about inheritance and Imports statement

      Robinson wrote:
      If you go to your project properties -References, you can import the
      reference for the entire project, rather than doing it on a file by file
      basis.

      You cannot use the Imports statement without first adding a reference
      to the corresponding assembly. In other words you cannot add a
      reference on a file by file basis. References are *always* added a
      project level.

      That said, the Imports statement has nothing to do with inheritance.
      It is simply a means of easing the amount of typing a developer has to
      do. Internally, the compiler works with the fully qualified type name.
      >
      "BillE" <belgie@datamti .comwrote in message
      news:eFPeOBNCHH A.2328@TK2MSFTN GP02.phx.gbl...
      Does a subclass have to import namespaces which were already imported by
      the superclass?

      I have a base class which imports the System.Data.SQL Client namespace to
      use the dataset member.

      When I inherit this base class, the subclass must also import the
      System.Data.SQL Client namespace to use its members.

      I thought that a subclass would not have to re-import namespaces which
      were already imported by the superclass.

      Do I understand correctly, or am I doing something wrong?

      Thanks
      Bill

      Comment

      • Robinson

        #4
        Re: question about inheritance and Imports statement

        You cannot use the Imports statement without first adding a reference
        to the corresponding assembly. In other words you cannot add a
        reference on a file by file basis. References are *always* added a
        project level.
        >
        That said, the Imports statement has nothing to do with inheritance.
        It is simply a means of easing the amount of typing a developer has to
        do. Internally, the compiler works with the fully qualified type name.
        Yes, but you can add a reference to the assembly AND import the namespace in
        project settings.


        Comment

        • Chris Dunaway

          #5
          Re: question about inheritance and Imports statement


          Robinson wrote:
          You cannot use the Imports statement without first adding a reference
          to the corresponding assembly. In other words you cannot add a
          reference on a file by file basis. References are *always* added a
          project level.

          That said, the Imports statement has nothing to do with inheritance.
          It is simply a means of easing the amount of typing a developer has to
          do. Internally, the compiler works with the fully qualified type name.
          >
          Yes, but you can add a reference to the assembly AND import the namespace in
          project settings.
          Ah yes! Your first post said "References " so I was thinking about
          adding a reference to another assembly, when you were actually
          referring to the References section in the properties page and the
          Imported Namespaces section on that.

          I primarily use C# which does not have this feature, hence my
          puzzlement.

          Comment

          Working...