Connecting Tech Pros Worldwide Help | Site Map

Associative Array

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 19th, 2005, 02:16 PM
Joe Rigley
Guest
 
Posts: n/a
Default Associative Array

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



  #2  
Old November 19th, 2005, 02:16 PM
Karl Seguin
Guest
 
Posts: n/a
Default Re: Associative Array

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" <jcrigley@spartanmotors.com> wrote in message
news:eOGn%23mAfFHA.2128@TK2MSFTNGP14.phx.gbl...[color=blue]
> 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
>
>[/color]


  #3  
Old November 19th, 2005, 02:16 PM
Joe Rigley
Guest
 
Posts: n/a
Default Re: Associative Array

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:%23bUQLrAfFHA.3864@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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" <jcrigley@spartanmotors.com> wrote in message
> news:eOGn%23mAfFHA.2128@TK2MSFTNGP14.phx.gbl...[color=green]
>> 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
>>
>>[/color]
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.