Generic Function (Of T) - and object GetType comparison
I've created the following basic function to determine whether specific control type is currently loaded:
开发者_如何学Go Private Function IsPreviewerTypeLoaded(Of T)() As Boolean
For Each previewer In LoadedPreviewers
If previewer.GetType().Equals(T) Then
End If
Next
End Function
I need to compare each control against the generic type supplied. Equals(T)
fails to do the job, producing a compiler error. How to make it correctly?
UPDATE: is the following correct?
previewer.GetType().Equals(GetType(T))
Private Function IsPreviewerTypeLoaded(Of T)() As Boolean
For Each previewer In LoadedPreviewers
If previewer.GetType().Equals(GetType(T)) Then
End If
Next
End Function
previewer.GetType().Equals(GetType(T)) //GetType = typeof in C#
精彩评论