The last line of C# code here will cause an error:
Cat cat = new Cat();
Lynx lynx = new Lynx();
Cat attemptedUpcast = (Cat) lynx;
Lynx attemptedDowncast = (Lynx) cat;
But none of the following lines of VB Script are problematic:
Partial Class VBform
Inherits System.Web.UI.Page
Dim snake As Snake
Dim viper As Viper
Dim attemptedUpcasting As Snake = CType(viper, Snake)
Dim attemptedDowncasting As Viper = DirectCast(snake, Viper)
End Class
No comments:
Post a Comment