views:

818

answers:

3
+5  Q: 

VB.NET := Operator

What does the following mean?

Class.Function(variable := 1 + 1)

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

A: 

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

Nescio
+9  A: 

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")
Ikke
A: 

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).

John Rudy