Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a backtick in a type name mean in the Visual Studio debugger?

When you Debug.Print some object types in the Visual Studio 2010 debugger, the output includes a backtick. What does the backtick mean?

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

Output in Immediate Window debugger:

System.Collections.Generic.List`1[System.String]
like image 260
bernie2436 Avatar asked Dec 21 '11 17:12

bernie2436


1 Answers

It's indicating the number of items in the subsequent array. The array contains the generic types.

List(Of String) has one generic type, namely string.

Try creating an SomeClass(Of T as String, U as Integer) and seeing what you get...

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

Output:

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

Two types: String, Int

Because of the structure, it's able to represent nested generic types in a tree-like fashion...

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

outputs

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

Two root types, one of which is generic: [String, Int], Int

like image 173
Basic Avatar answered Oct 26 '22 14:10

Basic