473,408 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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
Nov 19 '05 #1
2 2286
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" <jc******@spartanmotors.com> wrote in message
news:eO****************@TK2MSFTNGP14.phx.gbl...
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

Nov 19 '05 #2
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:%2****************@TK2MSFTNGP10.phx.gbl...
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" <jc******@spartanmotors.com> wrote in message
news:eO****************@TK2MSFTNGP14.phx.gbl...
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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Stefan Richter | last post by:
Hi, I want to create an associative Array with a PHP variable (article ID) as Key and another associative array as it's value. How do I instanciate it, how can I fill it? I want something...
27
by: Abdullah Kauchali | last post by:
Hi folks, Can one rely on the order of keys inserted into an associative Javascript array? For example: var o = new Object(); o = "Adam"; o = "Eve";
6
by: mark4asp | last post by:
Suppose I have the following code. It functions to randomly select a city based upon the probabilities given by the key differences in the associative array. . Eg. because the key difference...
4
by: Robert | last post by:
I am curious why some people feel that Javascript doesn't have associative arrays. I got these definitions of associative arrays via goggle: Arrays in which the indices may be numbers or...
8
by: Derek Basch | last post by:
Is there any way to associate name/value pairs during an array initialization? Like so: sType = "funFilter" filterTypeInfo = ; filterTypeInfo = new Array("type" : sType); I can do it using...
47
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
5
by: soup_or_power | last post by:
Hi I have an associative array like this: arr=30; arr=20;arr=40;arr=10; I want the sort function to sort keys in ascending order of the values on the right hand side with the following result:...
7
by: Robert Mark Bram | last post by:
Hi All! How do you get the length of an associative array? var my_cars= new Array() my_cars="Mustang"; my_cars="Station Wagon"; my_cars="SUV"; alert(my_cars.length);
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
11
by: Bosconian | last post by:
I'm trying to output the contents of an array of associative arrays in JavaScript. I'm looking for an equivalent of foreach in PHP. Example: var games = new Array(); var teams = new...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.