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]
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With