gpt4 book ai didi

vb.net - 类型名称中的反引号在 Visual Studio 调试器中意味着什么?

转载 作者:行者123 更新时间:2023-12-03 00:47:58 25 4
gpt4 key购买 nike

当您在 Visual Studio 2010 调试器中Debug.Print某些对象类型时,输出包含反引号。反引号是什么意思?

Dim myList as List = a List
Debug.Print(myList.GetType().ToString()

立即窗口调试器中的输出:

System.Collections.Generic.List`1[System.String]

最佳答案

它表示后续数组中的项目数。该数组包含泛型类型。

List(Of String) 有一种泛型类型,即 string

尝试创建一个 SomeClass(Of T as String, U as Integer) 并看看会得到什么...

Public Class TestGeneric(Of T, U)
Public Sub TellType(ByVal Something As T, ByVal SomethingElse As U)
Console.WriteLine(Me.GetType())
End Sub
End Class

Sub Main()
Dim MyTestGeneric As New TestGeneric(Of String, Integer)
MyTestGeneric.TellType("Test", 3)
Console.ReadKey(True)
End Sub

输出:

SO8593626.Program+TestGeneric`2[System.String,System.Int32]

两种类型:String、Int

由于结构的原因,它能够以树状方式表示嵌套的泛型类型...

    Dim MyTestGeneric As New TestGeneric(Of String, Integer)
Dim MyOtherGeneric As New TestGeneric(Of TestGeneric(Of String, Integer), Integer)
MyOtherGeneric.TellType(MyTestGeneric, 3)

输出

    SO8593626.Program+TestGeneric`2[SO8593626.Program+TestGeneric`2[System.String,System.Int32],System.Int32]

两种根类型,其中一种是通用的:[String, Int], Int

关于vb.net - 类型名称中的反引号在 Visual Studio 调试器中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8593626/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com