📄 virtualcalls.vb
字号:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Diagnostics
Imports System.Windows.Forms
Namespace CodeForChapter5cs
Public Class [MyClass]
Private myVar As Integer = 1
Public Property MyProperty() As Integer
Get
Return myVar
End Get
Set(ByVal value As Integer)
myVar = value
End Set
End Property
Private myVVar As Integer = 1
Public Overridable Property MyVirtualProperty() As Integer
Get
Return myVVar
End Get
Set(ByVal value As Integer)
myVVar = value
End Set
End Property
Public Sub Test1()
GC.Collect()
Dim sw As Stopwatch = Stopwatch.StartNew()
Dim total As Integer = 0
For i As Integer = 0 To 999999
total += Me.MyProperty
Next i
sw.Stop()
Dim millis As Long = sw.ElapsedMilliseconds
MessageBox.Show(total.ToString(), millis.ToString())
End Sub
Public Sub Test2()
GC.Collect()
Dim sw As Stopwatch = Stopwatch.StartNew()
Dim total As Integer = 0
For i As Integer = 0 To 999999
total += Me.MyVirtualProperty
Next i
sw.Stop()
Dim millis As Long = sw.ElapsedMilliseconds
MessageBox.Show(total.ToString(), millis.ToString())
End Sub
End Class
End Namespace
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -