⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1.vb

📁 This is a book about vb.you could learn this from this book
💻 VB
字号:

Imports System.Collections
Imports System

Public Structure Person
    
    Dim Name As String
    Dim Age As Integer
    
End Structure


Public Module Main

	public Sub Main()

		dim dictionary as Hashtable
		dim p as Person

		' Create a Hastable - this is a reference type, so we use New
		' to create the object on the managed CLR heap.

		dictionary = new Hashtable()

		' Setup our Person Structure - This is value type, so we do
		' not use New, and the type is just allocated on the stack.


		p.Name = "Richard Anderson"
		p.Age = 29

		' Add our Person value type to the dictionary.  This will cause
		' the value type to be boxed within a reference type, and added
		' to the dictionary.

		dictionary.Add( "Rich", p )

		' Setup the value type (overwriting the old values)

		p.Name = "Sam Anderson"
		p.Age = 28
		
		' Add our Person value type to the dictionary.  Again, this will cause
		' the value type to be boxed within a reference type and adde to the
		' dictionary.

		dictionary.Add( "Sam", p )

		' Retreive a person by Name.  The CType keyword tells VB that
		' the object type returned by the Item function is a Person
		' type.  Since the Person type is a value type, the CLR knows
		' to unbox the Person type from the returned object type.

		p = CType( dictionary.Item("Rich"), Person )

		' We use the Person type

		Console.WriteLine("Name is {0} and Age is {1}", _
			p.Name, p.Age )
		
		
	End Sub

End Module

⌨️ 快捷键说明

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