开发者

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#
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜