Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found two approaches which may help you. </p> <p>The more elegant one is to force your base to subclass by usage of a generic method without type inference. It could look something like (I'm not a VB.Net programmer so there may be some errors): </p> <pre><code>Sub SetFlat(of T) (myVehicle As T) T.IsFlatbed = True End Sub // later you can just call SetFlat(Of Truct)(myVehicle) </code></pre> <p>Of course this implies that you need to know the exact type of myVehicle object before calling SetFlat function. Also SetFlat can only be called with classes which do have the IsFlatbed property. Some more details about generics in VB.Net:<br> <a href="http://www.15seconds.com/issue/040526.htm" rel="nofollow noreferrer">http://www.15seconds.com/issue/040526.htm</a><br> <a href="http://msdn.microsoft.com/en-us/library/w256ka79%28VS.80%29.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/w256ka79%28VS.80%29.aspx</a><br> <a href="https://stackoverflow.com/questions/206982/generic-functions-in-vb-net">Generic Functions in VB.NET</a></p> <p>A second (dirty) solution is to use .Net reflection to detect if the myVehicle object contains the IsFlatbed property. You may find more details on:<br> <a href="http://msdn.microsoft.com/en-us/magazine/cc163750.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc163750.aspx</a><br> <a href="http://visualbasic.about.com/od/usingvbnet/a/proginfo.htm" rel="nofollow noreferrer">http://visualbasic.about.com/od/usingvbnet/a/proginfo.htm</a><br> <a href="http://www.eggheadcafe.com/community/aspnet/14/14989/reflection.aspx" rel="nofollow noreferrer">http://www.eggheadcafe.com/community/aspnet/14/14989/reflection.aspx</a></p>
    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