开发者

Generic Function (Of T) - and object GetType comparison

开发者 https://www.devze.com 2023-01-24 20:12 出处:网络
I\'ve created the following basic function to determine whether specific control type is currently loaded:

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

精彩评论

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

关注公众号