Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Visual J# / July 2004

Tip: Looking for answers? Try searching our database.

Equivalent of Associative Arrays in J#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 26 Jul 2004 03:41 GMT
The following JScript code uses associative array. How can
I achieve the same in J# ? Could someone please give a
similar J# example?

To understand, save the following as an HTML file and open
the file in IE.

Thanks,
Bob
////////////////////////
<html>
<head>
<script language="jscript">

function test(){

var myArray = [{name:"Mike", age:"29", sex:"m"},
{name:"Lisa", age:"28", sex:"f"}];
alert("Name: " + myArray[0].name);
alert("Age: " + myArray[0].age);
alert("Sex: " + myArray[0].sex);

}

</script>

</head>

<body onload="test()">

Test for Associative arrays in JScript

</body>

</html>
////////////////////////
David Browne - 26 Jul 2004 15:39 GMT
> The following JScript code uses associative array. How can
> I achieve the same in J# ? Could someone please give a
[quoted text clipped - 19 lines]
>
> }

J# is not a scripting language, you can't use J# as a client-side HTML
script.  J# is Java and and it is not loosely typed like JavaScript.

In Java you would do something like this:

class Person
{
 String name;
 int age;
 String sex;
 public Person(String name, int age, String sex)
 {
   this.name = name;
   this.age = age;
   this.sex = sex;
 }
}

. . .

 Person[] myArray = new Person[] {new Person("Mike", 29, "m"),
                                  new Person("Lisa", 28, "f")};
 System.out.println("Name: " + myArray[0].name);
 System.out.println("Age: " + myArray[0].age);
 System.out.println("Sex: " + myArray[0].sex);

David

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.