enumsession.aspx

来自「This is a book about vb.you could learn 」· ASPX 代码 · 共 94 行

ASPX
94
字号
<%@Page Language="VB" debug="true" %>
<%@ Import Namespace="System.IO" %>



<script runat=server>

	Dim  shoppingCart As Hashtable


	Class ShoppingCartItem

		Dim _productName As String
		Dim _quantityOrdered As Integer

		Public Overrides Function GetHashCode() As Integer
		
			Return 1
		
		End Function
	End Class
	
	
	Public Sub Page_Load(sender As Object, e As EventArgs)

		Dim ci As New ShoppingCartItem()

		Session("value1") = "Wrox"
		Session("value2") = "Press"

		Response.Write(Session(0))

		Dim s As String
		For Each s in Session
			Response.Write( "<BR>" & s)
		Next

		Response.Write( "<HR>")

		Dim ourSession As Hashtable

		' Case sensitive hashtable
		ourSession = New Hashtable()

		' Case insensitive hashtable

		ourSession = New Hashtable( CaseInsensitiveHashCodeProvider.Default, _
									CaseInsensitiveComparer.Default	 )

		ourSession("value1") = "Wrox"
		ourSession("value2") = "Press"


		ourSession(ci) = "fred"
		
		Dim value As String

		value = ourSession("value1")
		value = ourSession("value2")

		Dim entry As DictionaryEntry
		For Each entry in ourSession
			Response.Write("<BR>Key:" & entry.Key.ToString() & " Value:" & entry.Value.ToString() )
		Next


		If Not (ourSession("Value1") Is Nothing)
			Response.Write("<P>entry found")
		End If


		Dim hashcode As Integer
		Dim name As String = "Richard"
		

		hashcode = name.GetHashCode()
		Response.Write( "Hash code is " & hashcode )
		

		Dim names As StringDictionary
		Dim surname As String

		names = New StringDictionary()
		names("richard") = "anderson"
		names("alex") = "homer"

		surname = names("alex")

		Response.Write("The surname for alex is " & surname )

	End Sub

</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?