01.
<%@ Import Namespace=
"System.Collections.Specialized"
%>
02.
<%@ Page Language=
"C#"
Debug=
"true"
%>
03.
<script runat=
"server"
>
04.
void
Page_Load(
object
sender, EventArgs e)
05.
{
06.
StringDictionary objDict;
07.
int
i;
08.
objDict =
new
StringDictionary();
09.
10.
objDict.Add(
"white"
,
"#FFFFFF"
);
11.
objDict.Add(
"black"
,
"#000000"
);
12.
objDict.Add(
"red"
,
"#FF0000"
);
13.
objDict.Add(
"yellow"
,
"#FFFF00"
);
14.
objDict.Add(
"green"
,
"#00FF00"
);
15.
16.
objDict.Clear();
17.
18.
foreach
(String lsItem
in
objDict.Keys)
19.
{
20.
this
.lblText.Text =
this
.lblText.Text +
"Key = "
+ lsItem +
", Value = "
+ objDict[lsItem] +
"<br>"
;
21.
}
22.
}
23.
</script>
24.
<html>
25.
<head>
26.
<title>ThaiCreate.Com ASP.NET - StringDictionary</title>
27.
</head>
28.
<body>
29.
<form id=
"form1"
runat=
"server"
>
30.
<asp:Label id=
"lblText"
runat=
"server"
></asp:Label>
31.
</form>
32.
</body>
33.
</html>