??xml version="1.0" encoding="utf-8" standalone="yes"?>国产女同一区二区,精品在线免费观看,国产欧美一区二区精品久久久http://www.aygfsteel.com/kinoviti/category/5123.htmlzh-cnWed, 28 Feb 2007 03:12:12 GMTWed, 28 Feb 2007 03:12:12 GMT60AJAX Web Tree 构徏Ҏ及实现思想http://www.aygfsteel.com/kinoviti/archive/2006/01/27/29304.html-=Kino=--=Kino=-Fri, 27 Jan 2006 08:42:00 GMThttp://www.aygfsteel.com/kinoviti/archive/2006/01/27/29304.htmlhttp://www.aygfsteel.com/kinoviti/comments/29304.htmlhttp://www.aygfsteel.com/kinoviti/archive/2006/01/27/29304.html#Feedback3http://www.aygfsteel.com/kinoviti/comments/commentRss/29304.htmlhttp://www.aygfsteel.com/kinoviti/services/trackbacks/29304.html***************************************
关键字:AJAX,Tree,StrutsQDOM
难易度: ?BR>软g版本Qstruts 1.2.8
旉Q?006-01-27
AuthorQKino
***************************************


前阵子写了一个小代码处理AJAX下WebTree的构建,其中到了一些问题,也有一些想法,现在说出来希望大家一L看,如果案由问题请不吝赐教,本h不胜感激啊?BR>
背景Q?BR>q次因ؓ是加载在Struts上的开发,Web面上的Tree作AJAX处理Q因为有Node的增删改操作。Server端因和WebServiceq接Q所以不做Cache?BR>
解决案:
1。用Polling调用AJAX定期更新Tree?BR>2。AJAX讉K的地址是一个ActionQ例Qcreatetree.doQ。用来返回Tree模型或者错误消息(国际化)?BR>3。Browser解析XML的TreeModel?BR>4。在Browser比较新旧2个TreeModelQ完成选中状态的l承?BR>5。CSS渲染TreeNode?BR>
以上是简单的思\。传l的AJAX应该是尽量减XMl传输量,q于没有Cache的缘故,q且WSl我的节点ƈ不能单的得到父子关系。我选择了,每次Polling更新整棵树的Ҏ。性能未测?BR>
我这ơ在web server 端构建Tree时直接用深度优先转换成XML。XMl中数据的先后序军_了Tree从父到子Q从兄到弟的深度优先关系Qindent军_了深度(也就是羃q)。这h从Server端传入的也就成了一个标准的Tree昄Model。格式定义如下?BR>  * Gobal Master Tree DTD
 * &lt!ELEMENT tree (tree*)&gt
 * &lt!ATTLIST tree
 *  id   CDATA #REQUIRED LoctionInfo's toString
 *  indent  CDATA #REQUIRED Tree's Level
 *  text        CDATA   #REQUIRED label in html
 *  tooltip     CDATA   #IMPLIED title in html
 *  action      CDATA   #IMPLIED href in html
 *  icon        CDATA   #IMPLIED close icon with the node status
 *  openicon    CDATA   #IMPLIED open icon with the node status
 *  open        CDATA   #IMPLIED&gt node's open states ,default is false in server.
 *  target  CDATA #IMPLIED node's open target
 *
<span id="maintree">
 <tree id="Ajax" indent=0 text="Root" tooltip="Root" action="/logout.do" icon="" openicon= "" open="false"/>
 <tree id="110" indent=1 text="Node 1" tooltip="Node 1" action="/logout.do" icon="" openicon= "" open="false"/>
 <tree id="120" indent=2 text="Node 2" tooltip="Node 2" action="/logout.do" icon="" openicon= "" open="false"/>
 <tree id="12580" indent=2 text="Node 3" tooltip="Node 3" action="/logout.do" icon="" openicon= "" open="false"/>
 <tree id="user" indent=1 text="Node 4" tooltip="Node 4" action="/logout.do" icon="" openicon= "" open="false"/>
</span>

上边?Tree昄出来如下
Root
 ?BR> ├Node 1
 ?nbsp;   ?BR> ?nbsp;   ├Node 2
 ?nbsp;   └Node 3
 └Node 4
indent   是~进?BR>数据的先后顺序就是深度优先的遍历序?BR>

q样的数据到了BrowserQ会先被转成一个对象数l?BR>

 1// Tree Node object
 2// This function creates a node in the tree with the following arguments:
 3//    sId         - The node's index within the global nodes_array
 4//    iIndent    - The level within the tree hierarchy (0 = top)
 5//    sText      - The text displayed in the tree for this node
 6//    sTooltip     - the tool tip
 7//    oAction   - For a document, the address it will display when clicked
 8//    sIcon        - the node's icon 
 9//    sIconOpen    - the node's icon state
10//      bOpen - true  false
11function GMTreeNode(sId,iIndent,sText,sTooltip,sAction,sIcon,sIconOpen,bOpen,sTarget)
12{
13    if (sId) this.id = sId;
14    if (iIndent) this.indent = iIndent;
15    if (sText) this.text = sText;
16    if (sAction) this.action = sAction;
17    if (sTooltip) this.tooltip = sTooltip;
18    if (sIcon) this.icon = sIcon;
19    if (sIconOpen) this.iconopen = sIconOpen;
20    if (bOpen) this.open = bOpen;
21    if (sTarget) this.target = sTarget;
22    
23//    //alert(this.id + "  " + this.indent + "  " + this.text + "  " + this.action + "  " + 
24//    this.tooltip + "  " + this.icon + "  " + this.iconopen + "  " + this.open);
25}

然后会和正在昄的Tree数组 q行一?比较Q用于写入展开状态,代码如下Q?BR>
 1/////////////////////////////////
 2//    >>>Compare 
 3//    compare maintree with maintree. and copy maintree to maintree
 4/////////////////////////////////
 5function compareTreeModel()
 6{
 7    //alert("I am here in compareTreeModel");
 8    if (ajaxtree.length <= 0){
 9        alert("ajaxtree is null");//TODO
10        return;
11    }

12    
13    if (maintree.length <= 0){
14        //alert("maintree is null");
15        maintree = ajaxtree;
16        return;
17    }

18    //compare start
19    //var maxlen = Math.max(ajaxtree.length,maintree.length);
20    for(var i=0;i<ajaxtree.length;i++)
21    {
22        for(var j=0;j<maintree.length;j++)
23        {
24            if (ajaxtree[i].id == maintree[j].id)
25            {
26                ajaxtree[i].open = maintree[j].open;
27                break;
28            }

29        }
    
30    }

31    
32    maintree = ajaxtree;
33    
34}
maintree 是正在昄?TreeQajaxtree是刚得到的新Tree?个对象都是TreeNode的数l。而TreeNode对象的Open属性即记录了节点的展开状态。那么这里就对这个节点状态进行“移植”,完毕后,把新Tree模型交付昄ҎQ也是ToHtmlҎ?BR>
转换Html部分是一个比较容易出bug的危险点?BR>
首先分析一下,生成的代码是什么样子的?BR>q里仍然用上边的那棵树作例子?BR>生成的DOMl构应该?BR><div ?gt;
    <div  收羃>
    <img  折线  />
    <img  图标 />
    <a 节点动作>节点Label</a>
    <div ?gt;
        ....递归的构?BR>    </div ?gt;
    </div 收羃>
</div ?gt;

其次 对于q种q不直接含有父子关系的节炚w先要判明一个节点的??兄弟Q然后用递归解决?BR>递归的思\如下深度优先Q?BR>function toHtml(节点index)
{
   var child_htmlQ?BR>   if q个节点有子
   {
        Loop子节?BR>        {
               child_html[i] = toHtml(子节点index)Q?BR>               i++Q访问下一个子节点
   }
  
   var 所有子节点Html模块 = <div 收羃>   child_html.join("") </div>

   var 本节点Html模块 = <div 本节?gt;<div 收羃><img ><img  图标 /><a 节点动作>节点Label</a>所有子节点Html模块</div 收羃></div 本节?gt;;

   return  本节点Html模块;
}

树就构徏好了?BR>
作ؓ昄Q用了CSS?BR>background-repeat: repeat-y;
 background-image: url("../images/tree/I.png") !important;
 background-position-y: 1px !important; /* IE only */

q有padding-left作Div的向叛_U,默认的偏U量?9个像素点Q然后根据Tree昄模型的indent怹ok了?BR>
思\是q些。希望能?朋友们有所帮助?BR>Ƣ迎讨论?BR>

-=Kino=- 2006-01-27 16:42 发表评论
]]>
C#与JavaQ一Q?/title><link>http://www.aygfsteel.com/kinoviti/archive/2005/11/11/19257.html</link><dc:creator>-=Kino=-</dc:creator><author>-=Kino=-</author><pubDate>Fri, 11 Nov 2005 02:27:00 GMT</pubDate><guid>http://www.aygfsteel.com/kinoviti/archive/2005/11/11/19257.html</guid><wfw:comment>http://www.aygfsteel.com/kinoviti/comments/19257.html</wfw:comment><comments>http://www.aygfsteel.com/kinoviti/archive/2005/11/11/19257.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/kinoviti/comments/commentRss/19257.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/kinoviti/services/trackbacks/19257.html</trackback:ping><description><![CDATA[<P align=left><FONT size=6><STRONG>C#与JavaQ一Q?/STRONG></FONT><BR><BR><BR>************************************************<BR>关键字:l承<BR>难易度:?IMG height=20 src="http://www.aygfsteel.com/Emoticons/QQ/14.gif" width=20 border=0><BR>************************************************<BR><BR><BR>最q因为工作需要开展基于C#的研发。我在这里也写一点作为JavaE序员对于C#的部分感惛_。毕竟能力有限,请各位高手多多点拨?BR><BR>1.1实现的?BR><BR>C#和Java一样不能承private。但是C++可以在承中明确指出要承共有的q是U有的。如下:<BR><BR>q个是C#的承书写方法,作ؓ基类的CSharpBaseClassq没有限定符?/P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> CSharpClass QCSharpBaseClass<BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_35_45_Open_Image onclick="this.style.display='none'; Codehighlighter1_35_45_Open_Text.style.display='none'; Codehighlighter1_35_45_Closed_Image.style.display='inline'; Codehighlighter1_35_45_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_35_45_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_35_45_Closed_Text.style.display='none'; Codehighlighter1_35_45_Open_Image.style.display='inline'; Codehighlighter1_35_45_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_35_45_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_35_45_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">成员</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN></DIV> <P>q个是Java了,熟悉吧?/P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Class JavaClass </SPAN><SPAN style="COLOR: #0000ff">extends</SPAN><SPAN style="COLOR: #000000"> JavaBaseClass<BR><IMG id=Codehighlighter1_45_54_Open_Image onclick="this.style.display='none'; Codehighlighter1_45_54_Open_Text.style.display='none'; Codehighlighter1_45_54_Closed_Image.style.display='inline'; Codehighlighter1_45_54_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_45_54_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_45_54_Closed_Text.style.display='none'; Codehighlighter1_45_54_Open_Image.style.display='inline'; Codehighlighter1_45_54_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_45_54_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_45_54_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">成员</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN></DIV> <P>C++的定义如下:</P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> CPlusPlusClass: </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> CPlusPlusBaseClass<BR><IMG id=Codehighlighter1_48_58_Open_Image onclick="this.style.display='none'; Codehighlighter1_48_58_Open_Text.style.display='none'; Codehighlighter1_48_58_Closed_Image.style.display='inline'; Codehighlighter1_48_58_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_48_58_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_48_58_Closed_Text.style.display='none'; Codehighlighter1_48_58_Open_Image.style.display='inline'; Codehighlighter1_48_58_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_48_58_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_48_58_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">成员</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">}</SPAN></SPAN></DIV> <P>1.2虚函?BR><BR>把一个基cd数声明ؓvirtualQ该函数可以在MzcM重写了?BR>Java的语法中没有virtualq个词,但是Java却彻d底的贯彻着q个概念QJava的所有函数都是虚拟的?BR>C++的朋友可能比较熟悉这个词吧。对于这一点C#和C++是相同的。但是语法稍微有点不同,C#需要用overridecLC声明重写函数。如下例<BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> BaseClass<BR><IMG id=Codehighlighter1_16_158_Open_Image onclick="this.style.display='none'; Codehighlighter1_16_158_Open_Text.style.display='none'; Codehighlighter1_16_158_Closed_Image.style.display='inline'; Codehighlighter1_16_158_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_16_158_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_16_158_Closed_Text.style.display='none'; Codehighlighter1_16_158_Open_Image.style.display='inline'; Codehighlighter1_16_158_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_16_158_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_16_158_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>         </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">virtual</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> VirtualMethod()<BR><IMG id=Codehighlighter1_73_156_Open_Image onclick="this.style.display='none'; Codehighlighter1_73_156_Open_Text.style.display='none'; Codehighlighter1_73_156_Closed_Image.style.display='inline'; Codehighlighter1_73_156_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_73_156_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_73_156_Closed_Text.style.display='none'; Codehighlighter1_73_156_Open_Image.style.display='inline'; Codehighlighter1_73_156_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN id=Codehighlighter1_73_156_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_73_156_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>                   </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">The virtual method in defined in Base class</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> ChildClass : BaseClass<BR><IMG id=Codehighlighter1_190_338_Open_Image onclick="this.style.display='none'; Codehighlighter1_190_338_Open_Text.style.display='none'; Codehighlighter1_190_338_Closed_Image.style.display='inline'; Codehighlighter1_190_338_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_190_338_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_190_338_Closed_Text.style.display='none'; Codehighlighter1_190_338_Open_Image.style.display='inline'; Codehighlighter1_190_338_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_190_338_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_190_338_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>            </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">override</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> VirtualMethod()<BR><IMG id=Codehighlighter1_251_336_Open_Image onclick="this.style.display='none'; Codehighlighter1_251_336_Open_Text.style.display='none'; Codehighlighter1_251_336_Closed_Image.style.display='inline'; Codehighlighter1_251_336_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_251_336_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_251_336_Closed_Text.style.display='none'; Codehighlighter1_251_336_Open_Image.style.display='inline'; Codehighlighter1_251_336_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>        </SPAN><SPAN id=Codehighlighter1_251_336_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_251_336_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>                   </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">The override method in defined in child class</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>        }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV> <P><BR><BR>1.3隐藏Ҏ<BR>相同{֐的方法在基类和子c都声明了,但方法不是vitrual。那么实际中到底哪个Ҏ被执行,取决于引用实例的变量cdQ而不是实力本w的cd?BR>我们也不用太担心q个问题Q因为C#会在~译期给告?BR><BR>1.4调用U篏函数的方?BR>java中我们用superQC#中用base?BR><BR>1.5抽象cd抽象函数<BR>和java一样用abstract声明?BR>和C++相比QC++的抽象函数被声明为纯虚函数?BR><BR>1.6密封cd密封Ҏ<BR>在Java中我们把它叫做final。也是不能l承的类或不能重载的Ҏ?/P> <P>1.7构造函数的调用层次<BR>和Java一P我就不多说了。这里强调一个特D的语法格式Q?BR><BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> BaseClass<BR><IMG id=Codehighlighter1_23_280_Open_Image onclick="this.style.display='none'; Codehighlighter1_23_280_Open_Text.style.display='none'; Codehighlighter1_23_280_Closed_Image.style.display='inline'; Codehighlighter1_23_280_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_23_280_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_23_280_Closed_Text.style.display='none'; Codehighlighter1_23_280_Open_Image.style.display='inline'; Codehighlighter1_23_280_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_23_280_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_23_280_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> temp </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Default Construct</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> _flag<BR><IMG id=Codehighlighter1_88_141_Open_Image onclick="this.style.display='none'; Codehighlighter1_88_141_Open_Text.style.display='none'; Codehighlighter1_88_141_Closed_Image.style.display='inline'; Codehighlighter1_88_141_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_88_141_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_88_141_Closed_Text.style.display='none'; Codehighlighter1_88_141_Open_Image.style.display='inline'; Codehighlighter1_88_141_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN id=Codehighlighter1_88_141_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_88_141_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_98_112_Open_Image onclick="this.style.display='none'; Codehighlighter1_98_112_Open_Text.style.display='none'; Codehighlighter1_98_112_Closed_Image.style.display='inline'; Codehighlighter1_98_112_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_98_112_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_98_112_Closed_Text.style.display='none'; Codehighlighter1_98_112_Open_Image.style.display='inline'; Codehighlighter1_98_112_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN id=Codehighlighter1_98_112_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_98_112_Open_Text><SPAN style="COLOR: #000000">{ </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> temp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG id=Codehighlighter1_122_137_Open_Image onclick="this.style.display='none'; Codehighlighter1_122_137_Open_Text.style.display='none'; Codehighlighter1_122_137_Closed_Image.style.display='inline'; Codehighlighter1_122_137_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_122_137_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_122_137_Closed_Text.style.display='none'; Codehighlighter1_122_137_Open_Image.style.display='inline'; Codehighlighter1_122_137_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>     </SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN id=Codehighlighter1_122_137_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_122_137_Open_Text><SPAN style="COLOR: #000000">{ temp </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> value;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Constructor with one Parameter</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">  </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> BaseClass(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> f)<BR><IMG id=Codehighlighter1_258_278_Open_Image onclick="this.style.display='none'; Codehighlighter1_258_278_Open_Text.style.display='none'; Codehighlighter1_258_278_Closed_Image.style.display='inline'; Codehighlighter1_258_278_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_258_278_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_258_278_Closed_Text.style.display='none'; Codehighlighter1_258_278_Open_Image.style.display='inline'; Codehighlighter1_258_278_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN id=Codehighlighter1_258_278_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_258_278_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      flag </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> f;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>  }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> ChildClass : BaseClass<BR><IMG id=Codehighlighter1_319_1043_Open_Image onclick="this.style.display='none'; Codehighlighter1_319_1043_Open_Text.style.display='none'; Codehighlighter1_319_1043_Closed_Image.style.display='inline'; Codehighlighter1_319_1043_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_319_1043_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_319_1043_Closed_Text.style.display='none'; Codehighlighter1_319_1043_Open_Image.style.display='inline'; Codehighlighter1_319_1043_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_319_1043_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_319_1043_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG id=Codehighlighter1_372_373_Open_Image onclick="this.style.display='none'; Codehighlighter1_372_373_Open_Text.style.display='none'; Codehighlighter1_372_373_Closed_Image.style.display='inline'; Codehighlighter1_372_373_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_372_373_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_372_373_Closed_Text.style.display='none'; Codehighlighter1_372_373_Open_Image.style.display='inline'; Codehighlighter1_372_373_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>   </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> ChildClass():</SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Customized Construct</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_372_373_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_372_373_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_428_429_Open_Image onclick="this.style.display='none'; Codehighlighter1_428_429_Open_Text.style.display='none'; Codehighlighter1_428_429_Closed_Image.style.display='inline'; Codehighlighter1_428_429_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_428_429_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_428_429_Closed_Text.style.display='none'; Codehighlighter1_428_429_Open_Image.style.display='inline'; Codehighlighter1_428_429_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>   </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Second(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> f):</SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">BPara:CPara = 1:1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_428_429_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_428_429_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG id=Codehighlighter1_493_494_Open_Image onclick="this.style.display='none'; Codehighlighter1_493_494_Open_Text.style.display='none'; Codehighlighter1_493_494_Closed_Image.style.display='inline'; Codehighlighter1_493_494_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_493_494_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_493_494_Closed_Text.style.display='none'; Codehighlighter1_493_494_Open_Image.style.display='inline'; Codehighlighter1_493_494_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>   </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Second(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> f,</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> g):</SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">BPara:CPara = 1:2</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_493_494_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_493_494_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   </SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> showConstructFlag()<BR><IMG id=Codehighlighter1_543_966_Open_Image onclick="this.style.display='none'; Codehighlighter1_543_966_Open_Text.style.display='none'; Codehighlighter1_543_966_Closed_Image.style.display='inline'; Codehighlighter1_543_966_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_543_966_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_543_966_Closed_Text.style.display='none'; Codehighlighter1_543_966_Open_Image.style.display='inline'; Codehighlighter1_543_966_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>   </SPAN><SPAN id=Codehighlighter1_543_966_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_543_966_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Second();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Show ConstructFlag:\n ChildClass():base(\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Customized Construct\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">_Flag);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Second(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">test1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Show ConstructFlag:\n Second(string f,string g):base(\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">BPara:CPara </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">_Flag);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> Second(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">test2</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">no use</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Show ConstructFlag:\n Second(string f,string g):base(\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">BPara:CPara </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">\</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)=</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">_Flag);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>   <BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> Main()<BR><IMG id=Codehighlighter1_1006_1041_Open_Image onclick="this.style.display='none'; Codehighlighter1_1006_1041_Open_Text.style.display='none'; Codehighlighter1_1006_1041_Closed_Image.style.display='inline'; Codehighlighter1_1006_1041_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_1006_1041_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1006_1041_Closed_Text.style.display='none'; Codehighlighter1_1006_1041_Open_Image.style.display='inline'; Codehighlighter1_1006_1041_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN id=Codehighlighter1_1006_1041_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_1006_1041_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>        showConstructFlag();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV> <P>l果如预计那?Q?BR>如果基类含有带参数的构造函敎ͼzcM能调用默认基cL造函数?BR>多参数派生类构造函敎ͼ可以调用参数数目不同的基cL造函数?BR><BR>我们一h看看Z么这2个结论可以成立:<BR>首先Q对于带参数的基cL造函数在初始化的时候会试图去调用基c默认构造函敎ͼ但在上边的基cȝ序里Q因为只声明了带一个参数的构造函敎ͼ所以public Second(string f):base()或者public Second(string f)׃会通过~译Q因Z找不到基cȝ默认构造函敎ͼ只能q加<SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> BaseClass(</SPAN><SPAN style="COLOR: #000000">)才会通过。这一点和JAVA是不同的Qjava的默认构造函数默认是不出现在代码里的。C#却一定要写出来?BR><BR><<<== <FONT color=#ff0000>有错误。C#的默认构造函C制和Java是一L。具体如下:<BR>1。父cL有自定义构造函数的情况下,使用默认构造函数。用户可以不写出来?BR>2。一旦父cL了自定义的构造函敎ͼ那么如果要用无参的默认构造函数就必须要显C定义?/FONT><BR><BR><BR><BR><BR>其次Q下Ҏ生类1个参数?个参数甚臛_个参数的构造函Cؓ什么能讉K只有一个参数的基类构造函数呢Q原因是Q关键字thisQ上边的E序改写如下我想大家明白了?BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_49_50_Open_Image onclick="this.style.display='none'; Codehighlighter1_49_50_Open_Text.style.display='none'; Codehighlighter1_49_50_Closed_Image.style.display='inline'; Codehighlighter1_49_50_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_49_50_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_49_50_Closed_Text.style.display='none'; Codehighlighter1_49_50_Open_Image.style.display='inline'; Codehighlighter1_49_50_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Second(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> f):</SPAN><SPAN style="COLOR: #0000ff">base</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">BPara:CPara = 1:1</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_49_50_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_49_50_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG id=Codehighlighter1_108_109_Open_Image onclick="this.style.display='none'; Codehighlighter1_108_109_Open_Text.style.display='none'; Codehighlighter1_108_109_Closed_Image.style.display='inline'; Codehighlighter1_108_109_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_108_109_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_108_109_Closed_Text.style.display='none'; Codehighlighter1_108_109_Open_Image.style.display='inline'; Codehighlighter1_108_109_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> Second(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> f,</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> g):</SPAN><SPAN style="COLOR: #0000ff">this</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> f,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"><None</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">)</SPAN><SPAN id=Codehighlighter1_108_109_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_108_109_Open_Text><SPAN style="COLOR: #000000">{}</SPAN></SPAN></DIV> <P dir=ltr style="MARGIN-RIGHT: 0px"></SPAN>2.1修饰W?BR>C#支持下边的集中修饰符Q?BR>public Q?nbsp;  protected Q?internal  Qprivate Q?protected internal<BR>同Java。internal和protected internal?net framework新增的一个内宏V根据定义?BR>internal在同一个程序集内和publiccMQ不同的E序集间Qpublic声明的类或方法仍然可用,但是internal的方法或cd被隐藏?BR>protected internal合ƈ了protected 和internalQ但q是一Uor关系Q而不是and关系。protected internal成员在同一个程序集的Q何代码都可见Q在zcd见?BR><BR>2.3接口<BR>接口公约Q?BR>不能实例化接口?BR>接口不能有构造函数或字段?BR>接口定义也不允许包含q算W重载?BR>接口定义中还不允许声明成员上的修饰符。接口成员都是public的,不需要static也不需要virtual?BR><BR>同Java<BR>接口可以彼此l承Q其方式和类l承相同。如下:<BR><BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000"> my.test<BR><IMG id=Codehighlighter1_18_154_Open_Image onclick="this.style.display='none'; Codehighlighter1_18_154_Open_Text.style.display='none'; Codehighlighter1_18_154_Closed_Image.style.display='inline'; Codehighlighter1_18_154_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_18_154_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_18_154_Closed_Text.style.display='none'; Codehighlighter1_18_154_Open_Image.style.display='inline'; Codehighlighter1_18_154_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_18_154_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_18_154_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>  </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">interface</SPAN><SPAN style="COLOR: #000000"> IBase<BR><IMG id=Codehighlighter1_47_152_Open_Image onclick="this.style.display='none'; Codehighlighter1_47_152_Open_Text.style.display='none'; Codehighlighter1_47_152_Closed_Image.style.display='inline'; Codehighlighter1_47_152_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_47_152_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_47_152_Closed_Text.style.display='none'; Codehighlighter1_47_152_Open_Image.style.display='inline'; Codehighlighter1_47_152_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>  </SPAN><SPAN id=Codehighlighter1_47_152_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_47_152_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> setName();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #0000ff">bool</SPAN><SPAN style="COLOR: #000000"> isMe(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> name);<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>      </SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000"> name<BR><IMG id=Codehighlighter1_125_147_Open_Image onclick="this.style.display='none'; Codehighlighter1_125_147_Open_Text.style.display='none'; Codehighlighter1_125_147_Closed_Image.style.display='inline'; Codehighlighter1_125_147_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_125_147_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_125_147_Closed_Text.style.display='none'; Codehighlighter1_125_147_Open_Image.style.display='inline'; Codehighlighter1_125_147_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>      </SPAN><SPAN id=Codehighlighter1_125_147_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_125_147_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>         </SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>      }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>   }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/None.gif" align=top></SPAN><SPAN style="COLOR: #0000ff">namespace</SPAN><SPAN style="COLOR: #000000"> my.test<BR><IMG id=Codehighlighter1_175_243_Open_Image onclick="this.style.display='none'; Codehighlighter1_175_243_Open_Text.style.display='none'; Codehighlighter1_175_243_Closed_Image.style.display='inline'; Codehighlighter1_175_243_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_175_243_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_175_243_Closed_Text.style.display='none'; Codehighlighter1_175_243_Open_Image.style.display='inline'; Codehighlighter1_175_243_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedBlock.gif" align=top></SPAN><SPAN id=Codehighlighter1_175_243_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_175_243_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>    </SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">interface</SPAN><SPAN style="COLOR: #000000"> IChild:IBase<BR><IMG id=Codehighlighter1_215_241_Open_Image onclick="this.style.display='none'; Codehighlighter1_215_241_Open_Text.style.display='none'; Codehighlighter1_215_241_Closed_Image.style.display='inline'; Codehighlighter1_215_241_Closed_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_215_241_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_215_241_Closed_Text.style.display='none'; Codehighlighter1_215_241_Open_Image.style.display='inline'; Codehighlighter1_215_241_Open_Text.style.display='inline';" src="http://www.aygfsteel.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </SPAN><SPAN id=Codehighlighter1_215_241_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.aygfsteel.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_215_241_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/InBlock.gif" align=top>       </SPAN><SPAN style="COLOR: #0000ff">bool</SPAN><SPAN style="COLOR: #000000"> isOK();<BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.aygfsteel.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</SPAN></SPAN></DIV> <P dir=ltr style="MARGIN-RIGHT: 0px">告一D落吧?nbsp;                                (つづ?<BR><IMG height=20 src="http://www.aygfsteel.com/Emoticons/QQ/laf.gif" width=20 border=0>请多提意见,如果有什么不清楚的地方也请你写下来,一赯查咯?nbsp; <IMG height=20 src="http://www.aygfsteel.com/Emoticons/QQ/laf.gif" width=20 border=0></P><img src ="http://www.aygfsteel.com/kinoviti/aggbug/19257.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/kinoviti/" target="_blank">-=Kino=-</a> 2005-11-11 10:27 <a href="http://www.aygfsteel.com/kinoviti/archive/2005/11/11/19257.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Struts Logic标签?/title><link>http://www.aygfsteel.com/kinoviti/archive/2005/10/13/15446.html</link><dc:creator>-=Kino=-</dc:creator><author>-=Kino=-</author><pubDate>Thu, 13 Oct 2005 12:04:00 GMT</pubDate><guid>http://www.aygfsteel.com/kinoviti/archive/2005/10/13/15446.html</guid><wfw:comment>http://www.aygfsteel.com/kinoviti/comments/15446.html</wfw:comment><comments>http://www.aygfsteel.com/kinoviti/archive/2005/10/13/15446.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/kinoviti/comments/commentRss/15446.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/kinoviti/services/trackbacks/15446.html</trackback:ping><description><![CDATA[<P><BR><IMG height=20 src="http://www.aygfsteel.com/Emoticons/QQ/blink.gif" width=20 border=0>Struts Logic标签?IMG height=20 src="http://www.aygfsteel.com/Emoticons/QQ/blink.gif" width=20 border=0> <BR><BR>Keywords: Struts   Logic  标签  JSP<BR>隑ֺQ易<BR><BR>背景Q不知道是不是相应“与时俱q”的大号召。反正当今的JSP是越来越难懂了。不是说ȝQ而是因ؓ太简单了Q反而不懂了。都是因为引入了 标签库?q下好了Q除了基HTML,JSP语法外还要学很多标签库的用法。加油吧?BR><BR>概念Q?BR>Struts Logic标签库中的标{֏以根据特定的逻辑条g来控制输出网늚内容Q或者@环遍历集合中的所有元素。主要用于表C层的显C?BR>Logic标签库的标签大致分ؓ以下几类Q?BR><BR><BR>...没有旉写了。我倒,争取11月之前写完?BR></P><img src ="http://www.aygfsteel.com/kinoviti/aggbug/15446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/kinoviti/" target="_blank">-=Kino=-</a> 2005-10-13 20:04 <a href="http://www.aygfsteel.com/kinoviti/archive/2005/10/13/15446.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Java 异常处理http://www.aygfsteel.com/kinoviti/archive/2005/10/13/15420.html-=Kino=--=Kino=-Thu, 13 Oct 2005 06:15:00 GMThttp://www.aygfsteel.com/kinoviti/archive/2005/10/13/15420.htmlhttp://www.aygfsteel.com/kinoviti/comments/15420.htmlhttp://www.aygfsteel.com/kinoviti/archive/2005/10/13/15420.html#Feedback0http://www.aygfsteel.com/kinoviti/comments/commentRss/15420.htmlhttp://www.aygfsteel.com/kinoviti/services/trackbacks/15420.html
Java异常处理机制


keywords:

Exception,Method Inovation Stack,

隑ֺQ初学,?/FONT>


异常cȝl承
Java异常是javaE序q行旉到非正常情况而创建的一U对象,她包装了异常的信息?BR>Java异常的顶U类是java.lang.Throwable。其l构如下Q?BR>
JavaExceptionClass
其中

Error ---- JVM的错误,也就是程序本w无法恢复的严重错误?BR>
Exception--被程序捕获ƈ处理的异常?BR>


JVM的方法调用堆?/STRONG>
大家对于Debug都很喜欢Q因为每当有异常出现的时候,她会告诉你哪里出了异常调用到底是什么。这又是如何实现的?

在JVM中用了Method Inovation Stack机制来跟t每一个线E中一pd的方法调用过E。ƈ保存在Stack里边?BR>Stack的顶端也是当前正在处理的方法。在Debug的时候,JVM会暂停被debug的线E,克隆她的StackQ然后显C出来供

developer操作Q这一点用Eclipse的h很有体验吧?BR>


一旦异常发生,JVM首先从当前的Ҏ开始寻扑֤理的try/CatchQ找不到Q就回朔到stack的下一个,也就是parent调用

Ҏ。D例如下:

public void child(int a)throws UserException{
  
if (a < 0
     
throw new UserException();
}


父方法如下:

public void parent(int a){
  
try{
      a 
= 1;
      method(a);
//throw Exception
  }
catch(UserException ue){
      System.out.println(
"I get it from Child")!
      ue.printExceptionStack();
  }

}


pP异常被抓住了。当Ӟ如果在childҎ里边捕Pparent׃用这么“篏”了?BR>
其实最累的q是JVMQ她要对异常捕获q行查找Q如果一直都找不刎ͼ把异常直接抛给用户Q那么在l端上就能看

C。如果是抛出异常的程序是ȝQ还没有被捕P那就“死翘”了。要注意Q?BR>


异常处理Ҏ能的媄?/STRONG>

从上边的原理p知道Q不捕捉异常、捕捉异常的位置不合适、都会导致JVM性能降低?BR>


(PS:先记到这里,l箋上班?











-=Kino=- 2005-10-13 14:15 发表评论
]]>
վ֩ģ壺 | Զ| կ| | | ƽ| | | п| | | | ̫| ɽ| | | | | | ԫ| | Ұ| | | ޵| | Ӫɽ| | ϰ| | ľ˹| | ̨| | | Դ| | ĵ| ګ| | |