VB.NET := Operator

2019-01-26 10:49发布

What does the following mean?

Class.Function(variable := 1 + 1)

What is this operator called, and what does it do?

3条回答
Evening l夕情丶
2楼-- · 2019-01-26 11:35

It assigns the optional parameter "variable" the value 2.

查看更多
倾城 Initia
3楼-- · 2019-01-26 11:37

It is used to assign optional variables, without assigning the previous ones.

sub test(optional a as string = "", optional b as string = "")
   msgbox(a & b)
end sub

you can now do

test(b:= "blaat")
'in stead of
test("", "blaat")
查看更多
家丑人穷心不美
4楼-- · 2019-01-26 11:39

VB.NET supports this syntax for named (optional) parameters in method calls. This particular syntax informs Class.Function that its parameter variable is to be set to 2 (1 + 1).

查看更多
登录 后发表回答