【发布时间】:2010-09-17 07:41:21
【问题描述】:
以下是什么意思?
Class.Function(variable := 1 + 1)
这个操作符叫什么,它有什么作用?
【问题讨论】:
以下是什么意思?
Class.Function(variable := 1 + 1)
这个操作符叫什么,它有什么作用?
【问题讨论】:
它为可选参数“变量”分配值 2。
【讨论】:
用于分配可选变量,不分配前面的变量。
sub test(optional a as string = "", optional b as string = "")
msgbox(a & b)
end sub
你现在可以做
test(b:= "blaat")
'in stead of
test("", "blaat")
【讨论】:
DoTheThing(doItFast := True, doItNow := True...) 之类的操作,以便清楚我正在设置哪些标志(而不是DoTheThing(True, True, False, True, False, False, False) :P)
VB.NET 支持方法调用中命名(可选)参数的这种语法。这个特殊的语法通知Class.Function 它的参数variable 将被设置为2 (1 + 1)。
【讨论】: