精通ASP.NET(基于VB.NET)(四)VB.NET继承
(1) 理解继承:继承是实现相关类方法、接口等共享的一种手段。相关类是指类及其派生类。基于不同类实例的独特性,故引入了public、private、protected作用域和overrides(重写)、方法重载overloads。这样作的目的:提高代码的复用性。
(2)继承的种类:实现继承、接口继承和可视继承。
(3)接口:先看一例
Interface Inter_comm
sub read_x(by vlue x as integer)
Function write_x(by vlue x as integer) as long
Property pr_x() as string
end interface
class Inter_comm_made
Implements Inter_comm
private x as string
sub read_x(by vlue x as integer) Implements Inter_comm.read_x
end sub
Function write_x(byval x as integer) as long Implements Inter_comm.write_x
end function
Property pro_x() as string Implements Inter_comm.pr_x
get
return x
end get
set(byval value as string)
x=value
end set
end class
接口定义用Interface。实现用类或结构,用Implements指定。
本文地址:http://com.8s8s.com/it/it45660.htm