【发布时间】:2011-09-08 06:38:39
【问题描述】:
我以前见过这个,但直到现在我才真正对它的用途感兴趣。看看下面两个例子(哦,这都是在 VB.net 顺便说一句):
示例 1:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using nFD As New FontDialog
If nFD.ShowDialog = Windows.Forms.DialogResult.OK Then
LoadFont(_font:=nFD.Font)
End If
End Using
End Sub
Private Sub LoadFont(ByVal _font As Font)
MsgBox(_font.Name)
End Sub
示例 2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using nFD As New FontDialog
If nFD.ShowDialog = Windows.Forms.DialogResult.OK Then
LoadFont(nFD.Font)
End If
End Using
End Sub
Private Sub LoadFont(ByVal _font As Font)
MsgBox(_font.Name)
End Sub
两者的结果相同,您可能需要注意的主要是我设置参数的位置。设置参数时:= 的目的是什么。我假设它有某种比我刚刚试验的更重要的用途,但我不能谷歌它,因为谷歌不喜欢符号。
【问题讨论】: