Writing an asp.net mvc app and i have something like this...
Public Class AA
'... has some variables...
End Class
Public Class BB
Inherits AA
Public ExtraVariable As Integer ' just adds another variable and thats it!
End Class
So, now in my program, i just want to copy object of type AA to an empty variable of type BB?
it makes sense to do this, as i expect all the fields in AA type object to be copied to the newly created BB type object, and the ExtraVariable in the BB type object i would (will) just assign a value to it later (after the copy) on my own time!!
I know copying BB type to AA type would not be appropriate as there would be lost data!
But im trying to copy AA to BB, I've used both DirectCast
and CType
to do this, and i keep getting "unable to cast" error!!!
Note: I'm using vb.net (but can read c#, no problems)