This applies to both C# and VB, but VB also has type characters
var tuple = (int X = 1, int B = 2)
Dim tuple = (X as Integer := 1, Y As String := "2")
Dim tuple = (X% := 1, Y$ := "2")
Current implementations do not allow explicit typing. Need to confirm with LDM(s)
I also thought about this for the first time this week. Should modified identifiers be extended to support tuples?
Dim point(x As Integer, y As Integer) = GetOffset()
It's one of those 'feels VB' things but I think I need to noodle on it for a bit.
Another thing to consider is modified identifiers in tuple types -
Dim a As (x?() as Integer, y() As Integer?, z As Integer?())
Not sure if there is a C# analog for this.
For now I assume that modified identifiers are not allowed in tuple types.
And another, smaller, thing to consider whether under Strict Off
Dim x as (Ident1, Ident2()) ' is this (Ident As Object, Ident2 As Object()) when Strict Off ??
This one seems to be VB only.
Can we avoid doing this? It feels like adding unnecessary complexity to new concepts. If VB customers are really keen on using type characters then it make sense. If type characters are just something of a legacy feature I'd rather avoid them in new syntax forms.
@tmat - Type chars are hard to avoid. They are supported pretty deep in the lexer and are parts of VB identifier tokens. Some support for type chars is needed even if just giving an error that they are not expected.
Being a lexer feature, type chars do not impact parsing much, so it seems easier to just support them.
The rest of the things mentioned here do bring a lot of complexity to the grammar/parser/binder, with none of additional expressiveness or convenience.
How many different ways to say z As Integer?() are too many?
But there could be other opinions.
@VSadov If the complexity is limited to the lexer that's fine. I'm more worried about all IDE features and 3rd party analyzers that will need to handle complexity that can be avoided.

Hi, how can I enable this tuple language syntax? tuple is still not working on Preview 5 for VisualBasic
BC37267 Visual Basic AND VB.NET Predefined type is not defined or imported.
You need to install nuget package for ValueTuple into your project.
ValueTuple types are required for tuples to work and are not available (yet) by default
Great, it works!
Hi, Can we adding a new language syntax of VisualBasic type char as type cast operation for the VB Primitive types, example as:
Dim x As Double = 3.0
Dim y As Integer = x%
x% just working as the inline type cast operator CInt(x) if the primitive type can be casting, and I think this will makes the code more brevity
@xieguigang today the compiler insists that a reference to x uses the correct type character, if any, for the variable being referenced. So this would be a new meaning for that syntax that also turns off some type checking. It also would only apply to primitive types and to expressions that end in identifiers. I'm wary of adding another casting syntax for so narrow a scenario.
@AnthonyDGreen Hi, because of the gdi+ graphics drawing, mathematics calculation related framework development in the VisualBasic may required of a lot of usage of the primitive type, and some implicit type casting may exists. Due to the reason of Option explicit is OFF and Option strict is ON to following the company team coding rule, implicit type casting can not be compiled, so that a lot of inline type casting CStr, CInt may be used, and these will makes the code style not so nice-looking. And I think using the type char as the inline type casting would be good.
But still thanks a lot for reply my request. :-)
Option Explicit OFF or Option _Infer_ Of? Option Explicit just means you can use variables without explicitly declaring them.


@AnthonyDGreen NoNONONO, I means when Option explicit is OFF and Option strict is ON, the implicit type casting will be an error....... not Option Infer Off

This new inline type casting syntax looks better than the old style:

I think we decided that this would unnecessary complicate the feature.
Most helpful comment
You need to install nuget package for ValueTuple into your project.
ValueTuple types are required for tuples to work and are not available (yet) by default