Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You raise an interesting point about VB/C# compilation that I can't really speak to. If you're looking for a solution, here's a way to do it from the question <a href="https://stackoverflow.com/a/2478022/1366033">How can I recognize a generic class?</a></p> <p>Define these functions:</p> <pre class="lang-vb prettyprint-override"><code>Public Function IsSubclassOf(ByVal childType As Type, ByVal parentType As Type) As Boolean Dim isParentGeneric As Boolean = parentType.IsGenericType Return IsSubclassOf(childType, parentType, isParentGeneric) End Function Private Function IsSubclassOf(ByVal childType As Type, ByVal parentType As Type, ByVal isParentGeneric As Boolean) As Boolean If childType Is Nothing Then Return False End If If isParentGeneric AndAlso childType.IsGenericType Then childType = childType.GetGenericTypeDefinition() End If If childType Is parentType Then Return True End If Return IsSubclassOf(childType.BaseType, parentType, isParentGeneric) End Function </code></pre> <p>Call like this:</p> <pre class="lang-vb prettyprint-override"><code>Dim baseType As Type = GetType(MyBaseClass(Of )) Dim childType As Type = GetType(MyOtherChildClass) Console.WriteLine(IsSubclassOf(childType, baseType)) 'Writes: True </code></pre> <p>Here's a <a href="http://connect.microsoft.com/VisualStudio/feedback/details/95768/a-call-to-type-basetype-on-an-open-generic-hierarchy-will-produce-a-unexpected-typehandle" rel="nofollow noreferrer">Microsoft Connect Ticket</a> that might deal with this issue and give some explanation as to whether this was a feature or a bug of generic typing.</p> <p>Although this case doesn't seem supported by the <a href="http://msdn.microsoft.com/en-us/library/0ec5kw18.aspx" rel="nofollow noreferrer"><code>Type Of</code></a> documentation which states that for classes, typeof will return true if:</p> <blockquote> <p><em>objectexpression</em> is of type <em>typename</em> or <strong>inherits</strong> from <em>typename</em></p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload