In C#, we would sometimes declare a local variable by writing the expression first, then intorducing a local var out of it.
This way it gets its type automatically, and sometimes the proper name also.
When the var is introduced, the original expression is removed.
In VB, however, it is not. But it (1) should work as in C#, otherwise create-from-usage patterns are broken, and (2) it is a compilation error in most of the cases. Example:
Dim a As Integer = 1
a * Math.PI / 8
->
Dim a As Integer = 1
Dim angle As Double = a * Math.PI / 8
angle()
-> "Expression is not a method".
Description
In C#, we would sometimes declare a local variable by writing the expression first, then intorducing a local var out of it.
This way it gets its type automatically, and sometimes the proper name also.
When the var is introduced, the original expression is removed.
In VB, however, it is not. But it (1) should work as in C#, otherwise create-from-usage patterns are broken, and (2) it is a compilation error in most of the cases. Example:
Dim a As Integer = 1
a * Math.PI / 8
->
Dim a As Integer = 1
Dim angle As Double = a * Math.PI / 8
angle()