VS "15" preview 5 new functions of VB 15, vsvb
VS "15" preview 5 updates VB.
This update contains three content:
*ValueTuple
This function can return a group of computing results.
To use this function, we need to install the System. ValueTuple package. This is a test package, and I have carefully tested the value tuples of C.
After being installed, define a simple function
VB
Function TupleTest() As (Integer, b As String) Return (1, 2)End Function
The return value of this function contains two private fields and three public attributes.
The Member is used to put these two values. The attributes are
Item1, Item2, B
Here, B and Item2 point to the same field.
This is because the first member has no name and the default name is item1. The second parameter has the name B.
As for Item2, this may be a Bug, or it may have been designed to have a default name for each member in some anonymous tuples.
Currently, the value tuples do not support deconstruct or Option Explicit Off.
*Binary Number and digit Separator
Now we can use & B to define a binary number. For example:
VB
Enum MouseState None = &B0 Left = &B1 Right = &B10 Middle = &B100 X1 = &B1000 X2 = &B1_0000End Enum
Is it convenient?
*The ByRef return type is supported.
In C #, you can define a method or attribute for returning ref. Now VB can use this method normally. For example:
C #
public ref double Items(int index){ return ref this._collection[index];}
Use code in VB
VB
Items(0)=2.5
The first element of _ collection can be changed to 2.5 normally.
I personally think this function is only used for code compatible with c #7.0. This is because this function is somewhat difficult to write as an equivalent alternative. You can retrieve the value and copy it back without creating a reference.