先介绍一个包含继承所有要素的例子:
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/None.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/None.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockEnd.gif)
这个例子输出的结果是:
第一行是 parent.MethodA(); 输出的。
第二行是 child.MethodA();输出的。说明继承了,XParent中的方法。
第三行是 child.MethodB();输出的。XChild通过向集合添加一个方法来扩展XParent。
child.FieldA = 10;继承了属性。
下面是一个完整的列表,包括System.Object类中被重写的方法:
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/None.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/None.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/None.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockStart.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ContractedSubBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/InBlock.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedSubBlockEnd.gif)
![](/FCKeditor/editor/dialog/InsertCode/codeimages/ExpandedBlockEnd.gif)
文章来源: http://www.link-to.cn/post/2007/10/InheritExample.aspx