我无法在 vb 2017 中定义列表?

i can not define a list in vb 2017?

我在 Visual Studio 2019 年在我的个人电脑上写了这行,并且运行良好:

Dim coords = New List(Of (T1 As String, T2 As String, T3 As String, T4 As String, T5 As String))

这在我公司的计算机上不起作用,它有 Visual Studio 2017。

为什么这在 Visual Studio 2019 年有效,但在 Visual Studio 2017 年无效?

它在 VS 2019 中有效,因为你有一个 元组 的列表。 VS 2017 还不支持没有 a bit of extra work.

的元组

Tuple support requires the ValueTuple type. If the .NET Framework 4.7 is not installed, you must add the NuGet package System.ValueTuple, which is available on the NuGet Gallery. Without this package, you may get a compilation error similar to, "Predefined type 'ValueTuple(Of,,,)' is not defined or imported."

我想将此添加为对上述答案的评论,但显然我没有足够的分数(奇怪的系统)。

虽然 VS 2017 中可能不存在这样的推断元组,但您可以像这样手动创建一个元组:

    Dim Coords As List(Of Tuple(Of String, String, String))
    '...
    Coords.Add(New Tuple(Of String, String, String)("Item 1", "Item 2", "Item 3"))

这甚至在 VS 2010 中也有效。