how does using work?

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

    how does using work?

    Hi all

    I have the following that looks at a XSD Table adapter

    JobDescription. VWJobDescriptio nMinEducationDa taTable m_MinQuals;

    but for compactness I would like to reference it as

    Using JobDescription;

    VWJobDescriptio nMinEducationDa taTable m_MinQuals;



    but the 'using' part generates 'Error 1 A using namespace directive can only
    be applied to namespaces; 'JobDescription ' is a type not a namespace
    E:\Inetpub\wwwr oot\...' when I build the project

    can anyone help

    Andy



  • Morten Wennevik

    #2
    Re: how does using work?

    Hi Andy,

    I would guess that JobDescription is a class, and that VWJob...Table is a
    member of that class. In that case you would have to create an alias.

    using JDescMinTable = JobDescription. VWJobDescriptio nMinEducationDa taTable;

    JDescMinTable m_MinQuals;



    On Thu, 16 Nov 2006 13:48:27 +0100, AAJ <a.a.comwrote :
    Hi all
    >
    I have the following that looks at a XSD Table adapter
    >
    JobDescription. VWJobDescriptio nMinEducationDa taTable m_MinQuals;
    >
    but for compactness I would like to reference it as
    >
    Using JobDescription;
    >
    VWJobDescriptio nMinEducationDa taTable m_MinQuals;
    >
    >
    >
    but the 'using' part generates 'Error 1 A using namespace directive can
    only
    be applied to namespaces; 'JobDescription ' is a type not a namespace
    E:\Inetpub\wwwr oot\...' when I build the project
    >
    can anyone help
    >
    Andy
    >
    >
    >


    --
    Happy Coding!
    Morten Wennevik [C# MVP]

    Comment

    • Ciaran O''Donnell

      #3
      RE: how does using work?

      In C#, using aliases namespaces or classes.
      using System.Windows. Forms
      aliases System.Windows. Forms as nothingso you can access is members directly.
      using Forms = System.Windows. Forms
      aliases it as Forms so you can get to TextBox as Forms.TextBox
      using TB = System.Windows. Forms.TextBox
      aliases the class as TB and there fore you can access it like
      TB myTextbox = new TB();

      What you need to do for your needs is :

      using VWJobDescriptio nMinEducationDa taTable=
      JobDescription. VWJobDescriptio nMinEducationDa taTable

      Then you could write

      VWJobDescriptio nMinEducationDa taTable m_MinQuals;

      HTH


      Ciaran O'Donnell



      "AAJ" wrote:
      Hi all
      >
      I have the following that looks at a XSD Table adapter
      >
      JobDescription. VWJobDescriptio nMinEducationDa taTable m_MinQuals;
      >
      but for compactness I would like to reference it as
      >
      Using JobDescription;
      >
      VWJobDescriptio nMinEducationDa taTable m_MinQuals;
      >
      >
      >
      but the 'using' part generates 'Error 1 A using namespace directive can only
      be applied to namespaces; 'JobDescription ' is a type not a namespace
      E:\Inetpub\wwwr oot\...' when I build the project
      >
      can anyone help
      >
      Andy
      >
      >
      >
      >

      Comment

      • AAJ

        #4
        Re: how does using work?

        Thanks guys - its exactly what I was looking for

        cheers

        Andy


        "AAJ" <a.a.comwrote in message
        news:u1pGE2XCHH A.3228@TK2MSFTN GP03.phx.gbl...
        Hi all
        >
        I have the following that looks at a XSD Table adapter
        >
        JobDescription. VWJobDescriptio nMinEducationDa taTable m_MinQuals;
        >
        but for compactness I would like to reference it as
        >
        Using JobDescription;
        >
        VWJobDescriptio nMinEducationDa taTable m_MinQuals;
        >
        >
        >
        but the 'using' part generates 'Error 1 A using namespace directive can
        only be applied to namespaces; 'JobDescription ' is a type not a namespace
        E:\Inetpub\wwwr oot\...' when I build the project
        >
        can anyone help
        >
        Andy
        >
        >
        >

        Comment

        Working...