Associative Array

Discussion in 'ASP .Net' started by Joe Rigley, Jun 28, 2005.

  1. Joe Rigley

    Joe Rigley Guest

    I'm an ASP .Net newbie and need some help. Does ASP .NET support what I
    consider a "structure" or an "associative array"?

    I'm look for a data type that will hold a key name and a value such as this
    pseudo code below:

    Dim EmployeeInfoas (Structure or Associative Array?? What data type
    here???)

    'Add key and value:
    Employee.Add(<key>, <value>)
    Employee.Add("FullName","John Smith")
    Employee.Add("Phone","555-5555")

    'And then be referenced in this type of manner:
    response.write("Employee Name: " & Employee("FullName") & "<BR>")
    response.write("Phone: " & Employee("Phone"))
    'Or maybe there's a "Get" method or something... like Employee.Get("Phone")

    and the web page would write out:

    Employee Name: John Smith
    Phone: 555-5555

    The point is I'd like to use a string value to identify an index in an
    array, not an integer. Can anyone point me in the right direction here? Is
    this even possible? Please advise.

    Thanks,
    -Joe
     
    Joe Rigley, Jun 28, 2005
    #1
    1. Advertising

  2. Joe Rigley

    Karl Seguin Guest

    You want a system.collection.hashtable

    or a system.collection.specialized.namevaluecollection

    the latter being used when the key and value are strings, the former for any
    type of object..

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is
    annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)
    "Joe Rigley" <> wrote in message
    news:eOGn%...
    > I'm an ASP .Net newbie and need some help. Does ASP .NET support what I
    > consider a "structure" or an "associative array"?
    >
    > I'm look for a data type that will hold a key name and a value such as
    > this pseudo code below:
    >
    > Dim EmployeeInfoas (Structure or Associative Array?? What data type
    > here???)
    >
    > 'Add key and value:
    > Employee.Add(<key>, <value>)
    > Employee.Add("FullName","John Smith")
    > Employee.Add("Phone","555-5555")
    >
    > 'And then be referenced in this type of manner:
    > response.write("Employee Name: " & Employee("FullName") & "<BR>")
    > response.write("Phone: " & Employee("Phone"))
    > 'Or maybe there's a "Get" method or something... like
    > Employee.Get("Phone")
    >
    > and the web page would write out:
    >
    > Employee Name: John Smith
    > Phone: 555-5555
    >
    > The point is I'd like to use a string value to identify an index in an
    > array, not an integer. Can anyone point me in the right direction here?
    > Is this even possible? Please advise.
    >
    > Thanks,
    > -Joe
    >
    >
     
    Karl Seguin, Jun 28, 2005
    #2
    1. Advertising

  3. Joe Rigley

    Joe Rigley Guest

    Karl,

    Thanks very much for the quick response... I'm just working with Strings so
    the latter should be great!

    Much obliged,
    -Joe


    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    wrote in message news:%...
    > You want a system.collection.hashtable
    >
    > or a system.collection.specialized.namevaluecollection
    >
    > the latter being used when the key and value are strings, the former for
    > any type of object..
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/ - New and Improved (yes, the popup is
    > annoying)
    > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    > come!)
    > "Joe Rigley" <> wrote in message
    > news:eOGn%...
    >> I'm an ASP .Net newbie and need some help. Does ASP .NET support what I
    >> consider a "structure" or an "associative array"?
    >>
    >> I'm look for a data type that will hold a key name and a value such as
    >> this pseudo code below:
    >>
    >> Dim EmployeeInfoas (Structure or Associative Array?? What data type
    >> here???)
    >>
    >> 'Add key and value:
    >> Employee.Add(<key>, <value>)
    >> Employee.Add("FullName","John Smith")
    >> Employee.Add("Phone","555-5555")
    >>
    >> 'And then be referenced in this type of manner:
    >> response.write("Employee Name: " & Employee("FullName") & "<BR>")
    >> response.write("Phone: " & Employee("Phone"))
    >> 'Or maybe there's a "Get" method or something... like
    >> Employee.Get("Phone")
    >>
    >> and the web page would write out:
    >>
    >> Employee Name: John Smith
    >> Phone: 555-5555
    >>
    >> The point is I'd like to use a string value to identify an index in an
    >> array, not an integer. Can anyone point me in the right direction here?
    >> Is this even possible? Please advise.
    >>
    >> Thanks,
    >> -Joe
    >>
    >>

    >
    >
     
    Joe Rigley, Jun 28, 2005
    #3
  4. Joe Rigley

    dvega

    Joined:
    Oct 14, 2009
    Messages:
    1
    Associative Array in ASP 3.0 and ASP.NET

    you can create associative arrays with the "ASP Associative Array Class" (a VbScript Class); you will be able to use associative arrays as in PHP... you can also save database data (from MySQL, Access...) in an associative array or export well structured data; it's need to include this class in your *.asp files; download the class and tutorial from:

    maxvergelli.wordpress.com/2009/10/10/use-asp-associative-arrays/


    ps: there is also a porting for VB.NET/ASP.NET
     
    dvega, Oct 14, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nospam
    Replies:
    2
    Views:
    619
    Mohammd M. Hussain
    Jun 26, 2004
  2. desktop
    Replies:
    5
    Views:
    386
    James Kanze
    Jun 26, 2007
  3. Yvon Thoraval
    Replies:
    5
    Views:
    209
    Jason Creighton
    Sep 17, 2003
  4. VK
    Replies:
    47
    Views:
    547
    Thomas 'PointedEars' Lahn
    Jul 13, 2005
  5. VK
    Replies:
    36
    Views:
    651
    Martin Honnen
    Aug 3, 2005
Loading...

Share This Page