01.
<%@ Import
Namespace
=
"System.Collections.Specialized"
%>
02.
<%@ Page Language=
"VB"
%>
03.
<script runat=
"server"
>
04.
Sub
Page_Load(sender
As
Object
, e
As
EventArgs)
05.
Dim
objDict
As
StringDictionary
06.
Dim
i
As
Integer
07.
Dim
lsItem
As
String
08.
09.
objDict =
New
StringDictionary
10.
11.
objDict.Add(
"white"
,
"#FFFFFF"
)
12.
objDict.Add(
"black"
,
"#000000"
)
13.
objDict.Add(
"red"
,
"#FF0000"
)
14.
objDict.Add(
"yellow"
,
"#FFFF00"
)
15.
objDict.Add(
"green"
,
"#00FF00"
)
16.
17.
For
Each
lsItem
In
objDict.Keys
18.
Me
.lblText1.Text =
Me
.lblText1.Text &
"Key = "
& lsItem &
", Value = "
& objDict(lsItem) &
"<br>"
19.
Next
20.
21.
Me
.lblText2.Text = objDict(
"red"
)
22.
23.
End
Sub
24.
</script>
25.
<html>
26.
<head>
27.
<title>ThaiCreate.Com ASP.NET - StringDictionary</title>
28.
</head>
29.
<body>
30.
<form id=
"form1"
runat=
"server"
>
31.
<asp:Label id=
"lblText1"
runat=
"server"
></asp:Label>
32.
<br /><br />
33.
<asp:Label id=
"lblText2"
runat=
"server"
></asp:Label>
34.
</form>
35.
</body>
36.
</html>