E:\web\learnaspcom\htdocs\freebook\learn\ubtoc.xml LearnAsp.com - ASP ASP.net Free Lessons
Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll
<Asp.net blog>
<personal site>
xxx

Hashtable DataType by Charles Carroll

.net offers many rich data types and the ability to create your own. My personal favorite is a hashtable. .net also offers ArrayLists, Ques and Stacks as data types as well.

This example will show you all the basic syntax of manipulating and displaying a hashtable:

   filename=\experiments\hashtable\basics.aspx

<Test Script Below>


<%@ import namespace="system.collections"%>
<%@Page Language="VB" Trace="True" %>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs) 
    dim hashTest as new hashtable
    hashtest.add("fname","Hitoshi")
    hashtest.add("lname","Carroll")
    hashtest.add("bday","6/16/1998")
    
    If hashtest.contains("fname") THEN
        trace.write ("SUB page_load","First Name is" & hashtest("fname"))
    ELSE
        trace.write ("SUB page_load","Subject has no First Name")
    END IF
    
    Call Trace_HashTable(hashtest,"hashtest")
End Sub

SUB Trace_HashTable(p1 as HashTable,p2HashName as string)
    Trace.write("SUB Trace_Hashtable", p2HashName & " count=" & p1.count())
    Dim d As DictionaryEntry
    For Each d IN p1
        Trace.Write("SUB Trace_Hashtable", p2HashName & " " & d.Key & "=" & d.Value)
    Next d    
END SUB
</script>
<html><head>
<title>Radio Buttons from States</title>
</head>
<body bgcolor="#FFFFFF">
</body></html>

There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too. a $5 tip buys him lunch at McDonalds, a $20 tip buys his kid Hitoshi a new computer game, a $39 tip buys his daughter Michiko a few nice outfits. See our donor list.