锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品无码亚洲精品2021 ,最新国产AV无码专区亚洲,亚洲视频免费观看http://www.tkk7.com/killme2008/category/19912.htmlzh-cnMon, 09 Apr 2007 04:35:15 GMTMon, 09 Apr 2007 04:35:15 GMT60寰蔣涓篤S.net娣誨姞鍗曞厓嫻嬭瘯鍔熻兘http://www.tkk7.com/killme2008/archive/2007/04/09/109316.htmldennisdennisMon, 09 Apr 2007 00:37:00 GMThttp://www.tkk7.com/killme2008/archive/2007/04/09/109316.htmlhttp://www.tkk7.com/killme2008/comments/109316.htmlhttp://www.tkk7.com/killme2008/archive/2007/04/09/109316.html#Feedback0http://www.tkk7.com/killme2008/comments/commentRss/109316.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/109316.htmlinfoq涓枃绔?/a>


dennis 2007-04-09 08:37 鍙戣〃璇勮
]]>
C#瀹炵幇浜屽弶鏌ユ壘鏍?/title><link>http://www.tkk7.com/killme2008/archive/2007/04/02/108018.html</link><dc:creator>dennis</dc:creator><author>dennis</author><pubDate>Mon, 02 Apr 2007 09:29:00 GMT</pubDate><guid>http://www.tkk7.com/killme2008/archive/2007/04/02/108018.html</guid><wfw:comment>http://www.tkk7.com/killme2008/comments/108018.html</wfw:comment><comments>http://www.tkk7.com/killme2008/archive/2007/04/02/108018.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/killme2008/comments/commentRss/108018.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/killme2008/services/trackbacks/108018.html</trackback:ping><description><![CDATA[<p>浜屽弶鏌ユ壘鏍戯紙binary search tree)</p> <p>1錛夋蹇碉細瀵逛簬鏍戜腑鐨勬瘡涓妭鐐筺錛屽叾宸﹀瓙鑺傜偣涓繚瀛樼殑鎵鏈夋暟鍊奸兘灝忎簬n淇濆瓨鐨勬暟鍊鹼紝鍙沖瓙鑺傜偣淇濆瓨鐨勬暟鍊奸兘澶т簬n淇濆瓨鐨勬暟鍊箋?/p> <p>2錛変簩鍙夋煡鎵炬爲鍙互瀹炵幇鏇翠負浼樿秺鐨勬煡鎵炬ц兘錛屼富瑕佸疄鐜版柟寮忔湁鏁扮粍鍜岄摼琛ㄧ粨鏋勶紝鐩告瘮杈冭岃█錛岄摼琛ㄥ疄鐜版洿涓哄鏄擄紝鍥犱負鏁扮粍瀹炵幇鍒犻櫎鍜屾坊鍔犲姛鑳介渶瑕佺Щ鍔ㄦ暟緇勫厓绱狅紙濡傚~琛ュ垹闄ょ┖浣嶇瓑錛?/p> <br>浠婂ぉ涓嬪崍鍦ㄦ墦鍗伴棶棰樻悶瀹氬悗鐢–#瀹炵幇浜嗕竴涓嬶紝姣攋ava鐗堟湰姣旇緝鏈夎叮鐨勪嬌鐢–#鐨刣elegate鏉ヤ唬鏇塊亶鍘嗕簩鍙夋爲鏃剁殑visit鏂規(guī)硶錛岃繖鏍蜂竴鏉ュ彲浠ュ湪閬嶅巻鏃跺鑺傜偣榪涜浣犳墍鎯寵鐨勪換浣曟搷浣溿傛垜浠煡閬揅#鐨刣elegate鏄被鍨嬪寲鐨勫嚱鏁版寚閽堬紝鑰孋++鐨勫嚱鏁版寚閽堝彲浠ユā浠垮姩鎬佽璦鐨勯棴鍖呮垨鑰呭尶鍚嶅嚱鏁般傝繖閲屼篃鏈夎繖鏍風殑鍛抽亾銆?br><br>浠g爜濡備笅錛屽彧瀹炵幇浜嗘暣鏁板瀷鐨勶紝鑺傜偣瀹氫箟錛?br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">  </span><span style="color: #0000ff;">public</span><span style="color: #000000;">  </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> BSTIntNode<br>    {<br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> value;<br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BSTIntNode left;<br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BSTIntNode right;<br><br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BSTIntNode(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> value, BSTIntNode left, BSTIntNode right)<br>        {<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.value </span><span style="color: #000000;">=</span><span style="color: #000000;"> value;<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.left </span><span style="color: #000000;">=</span><span style="color: #000000;"> left;<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.right </span><span style="color: #000000;">=</span><span style="color: #000000;"> right;<br>        }<br><br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BSTIntNode(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> value)<br>        {<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.value </span><span style="color: #000000;">=</span><span style="color: #000000;"> value;<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.left </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.right </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>        }<br>    }</span></div> <br>鐒跺悗瀹氫箟涓涓狣elegate錛屼綔涓洪亶鍘嗘椂鐨勮闂柟娉曪細<br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"> </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">delegate</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> Visit(BSTIntNode node);</span></div> <br>鐒跺悗灝辨槸浜屽弶鏍戠殑瀹炵幇錛屽垹闄ょ畻娉曞彧瀹炵幇浜嗗鍒跺垹闄ゆ硶錛?br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> BSTIntTree<br>    {<br>        </span><span style="color: #0000ff;">protected</span><span style="color: #000000;"> BSTIntNode root;<br>      <br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> Visit visit;<br><br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BSTIntTree()<br>        {<br>            </span><span style="color: #0000ff;">this</span><span style="color: #000000;">.root </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>        }<br><br>        </span><span style="color: #0000ff;">private</span><span style="color: #000000;"> BSTIntNode Search(BSTIntNode node, </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> el)<br>        {<br>            </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (node </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (el </span><span style="color: #000000;">==</span><span style="color: #000000;"> node.value)<br>                    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> node;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (el </span><span style="color: #000000;"><</span><span style="color: #000000;"> node.value)<br>                    node </span><span style="color: #000000;">=</span><span style="color: #000000;"> node.left;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                    node </span><span style="color: #000000;">=</span><span style="color: #000000;"> node.right;<br>            }<br>            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br>        }<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">鏌ユ壘</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> BSTIntNode Search(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> el)<br>        {<br>            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> Search(root, el);<br>        }<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">騫垮害浼樺厛閬嶅巻,鍒╃敤闃熷垪瀹炵幇,鑷充笂鑰屼笅錛岃嚦宸﹁屽彸</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> BreadthFirst()<br>        {<br>            BSTIntNode p </span><span style="color: #000000;">=</span><span style="color: #000000;"> root;<br>            Queue queue </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> ListQueue();<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                queue.Enqueue(p);<br>                </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">queue.IsEmpty())<br>                {<br>                    p </span><span style="color: #000000;">=</span><span style="color: #000000;"> (BSTIntNode)queue.Dequeue();<br>                    visit(p);<br>                    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p.left </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>                        queue.Enqueue(p.left);<br>                    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p.right </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>                        queue.Enqueue(p.right);<br>                }<br>            }<br>        }<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">娣卞害浼樺厛閬嶅巻錛岄掑綊瀹炵幇綰垮簭錛屼腑搴忓拰鍚庡簭<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">鍏堝簭</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">protected</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> PreOrder(BSTIntNode p)<br>        {<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                visit(p);<br>                PreOrder(p.left);<br>                PreOrder(p.right);<br>            }<br>        }<br><br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> PreOrder()<br>        {<br>            PreOrder(root);<br>        }<br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">涓簭</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">protected</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> InOrder(BSTIntNode p)<br>        {<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                InOrder(p.left);<br>                visit(p);<br>                InOrder(p.right);<br>            }<br>        }<br><br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> InOrder()<br>        {<br>            InOrder(root);<br>        }<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">鍚庡簭</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">protected</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> PostOrder(BSTIntNode p)<br>        {<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                PostOrder(p.left);<br>                PostOrder(p.right);<br>                visit(p);<br>            }<br>        }<br><br>        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> PostOrder()<br>        {<br>            PostOrder(root);<br>        }<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">鎻掑叆鑺傜偣鎿嶄綔</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> Insert(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> el)<br>        {<br>            BSTIntNode p </span><span style="color: #000000;">=</span><span style="color: #000000;"> root, prev </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br><br>            </span><span style="color: #008000;">//</span><span style="color: #008000;">鏌ユ壘鑺傜偣浣嶇疆</span><span style="color: #008000;"><br></span><span style="color: #000000;">            </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                prev </span><span style="color: #000000;">=</span><span style="color: #000000;"> p;<br>                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p.value </span><span style="color: #000000;"><</span><span style="color: #000000;"> el)<br>                    p </span><span style="color: #000000;">=</span><span style="color: #000000;"> p.right;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                    p </span><span style="color: #000000;">=</span><span style="color: #000000;"> p.left;<br>            }<br><br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (root </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)  </span><span style="color: #008000;">//</span><span style="color: #008000;">絀烘爲</span><span style="color: #008000;"><br></span><span style="color: #000000;">                root </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BSTIntNode(el);<br>            </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (prev.value </span><span style="color: #000000;"><</span><span style="color: #000000;"> el)   </span><span style="color: #008000;">//</span><span style="color: #008000;">澶т簬鑺傜偣錛屾彃鍏ュ彸瀛愭爲</span><span style="color: #008000;"><br></span><span style="color: #000000;">                prev.right </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BSTIntNode(el);<br>            </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                prev.left </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BSTIntNode(el);<br>        }<br><br>        </span><span style="color: #008000;">//</span><span style="color: #008000;">澶嶅埗鍒犻櫎娉曠殑瀹炵幇錛屽綊騫跺垹闄ゆ硶鍙兘鏀瑰彉鏍戠殑楂樺害</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">public</span><span style="color: #000000;"> </span><span style="color: #0000ff;">void</span><span style="color: #000000;"> Delete(</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> el)<br>        {<br>            BSTIntNode node, p </span><span style="color: #000000;">=</span><span style="color: #000000;"> root, prev </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">;<br><br>            </span><span style="color: #008000;">//</span><span style="color: #008000;">鏌ユ壘鑺傜偣浣嶇疆</span><span style="color: #008000;"><br></span><span style="color: #000000;">            </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">&&</span><span style="color: #000000;">p.value</span><span style="color: #000000;">!=</span><span style="color: #000000;">el)<br>            {<br>                prev </span><span style="color: #000000;">=</span><span style="color: #000000;"> p;<br>                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p.value </span><span style="color: #000000;"><</span><span style="color: #000000;"> el)<br>                    p </span><span style="color: #000000;">=</span><span style="color: #000000;"> p.right;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                    p </span><span style="color: #000000;">=</span><span style="color: #000000;"> p.left;<br>            }<br>            node </span><span style="color: #000000;">=</span><span style="color: #000000;"> p;<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;"> </span><span style="color: #000000;">&&</span><span style="color: #000000;"> p.value </span><span style="color: #000000;">==</span><span style="color: #000000;"> el)<br>            {<br>                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (node.right </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>                    node </span><span style="color: #000000;">=</span><span style="color: #000000;"> node.left;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (node.left </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>                    node </span><span style="color: #000000;">=</span><span style="color: #000000;"> node.right;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                {<br>                    BSTIntNode temp </span><span style="color: #000000;">=</span><span style="color: #000000;"> node.left;<br>                    BSTIntNode previous </span><span style="color: #000000;">=</span><span style="color: #000000;"> node;<br>                    </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (temp.right </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)  </span><span style="color: #008000;">//</span><span style="color: #008000;">鏌ユ壘宸﹀瓧鑺傛暟鐨勬渶鍙沖瓙鑺傜偣</span><span style="color: #008000;"><br></span><span style="color: #000000;">                    {<br>                        previous </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp;<br>                        temp </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp.right;<br>                    }<br>                    node.value </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp.value;<br>                    </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (previous </span><span style="color: #000000;">==</span><span style="color: #000000;"> node)<br>                        previous.left </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp.left;<br>                    </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                        previous.right </span><span style="color: #000000;">=</span><span style="color: #000000;"> temp.left;<br>                }<br>                </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">==</span><span style="color: #000000;"> root)<br>                    root </span><span style="color: #000000;">=</span><span style="color: #000000;"> node;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (prev.left </span><span style="color: #000000;">==</span><span style="color: #000000;"> p)<br>                    prev.left </span><span style="color: #000000;">=</span><span style="color: #000000;"> node;<br>                </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                    prev.right </span><span style="color: #000000;">=</span><span style="color: #000000;"> node;<br>            }<br>            </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (root </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">null</span><span style="color: #000000;">)<br>            {<br>                Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">娌℃湁鎵懼埌鑺傜偣錛歿0}</span><span style="color: #000000;">"</span><span style="color: #000000;">, el);<br>            }<br>            </span><span style="color: #0000ff;">else</span><span style="color: #000000;"><br>                Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">鏍戜負絀猴紒</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>        }<br><br>    }</span></div> <br>娉ㄦ剰錛屽湪鏍戜腑鎴戜滑緇存寔浜嗕竴涓猇isit鐨刣elegate錛岀湅鐪嬩嬌鐢ㄦ柟娉曪細<br><br> <div style="border: 1px solid #cccccc; padding: 4px 5px 4px 4px; background-color: #eeeeee; font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;"> </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(</span><span style="color: #0000ff;">string</span><span style="color: #000000;">[] args)<br>        {<br>           BSTIntTree tree</span><span style="color: #000000;">=</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> BSTIntTree();<br>           </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> []num</span><span style="color: #000000;">=</span><span style="color: #000000;">{</span><span style="color: #000000;">10</span><span style="color: #000000;">,</span><span style="color: #000000;">20</span><span style="color: #000000;">,</span><span style="color: #000000;">6</span><span style="color: #000000;">,</span><span style="color: #000000;">12</span><span style="color: #000000;">,</span><span style="color: #000000;">23</span><span style="color: #000000;">,</span><span style="color: #000000;">15</span><span style="color: #000000;">,</span><span style="color: #000000;">8</span><span style="color: #000000;">};<br>           </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> num.Length; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>               tree.Insert(num[i]);<br>           </span><span style="color: #008000;">//</span><span style="color: #008000;">娣誨姞閬嶅巻澶勭悊鍑芥暟錛屽彲浠ユ湁澶氫釜 </span><span style="color: #008000;"><br></span><span style="color: #000000;">           tree.visit </span><span style="color: #000000;">+=</span><span style="color: #000000;"> </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Visit(printNode);<br>          <br>           Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">騫垮害浼樺厛閬嶅巻</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>           tree.BreadthFirst();<br>           Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">鍏堝簭</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>           tree.PreOrder();<br>           Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">涓簭</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>           tree.InOrder();<br>           Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">鍚庡簭</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>           tree.PostOrder();<br><br>           tree.Delete(</span><span style="color: #000000;">8</span><span style="color: #000000;">);<br>           tree.Delete(</span><span style="color: #000000;">15</span><span style="color: #000000;">);<br>           Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">鍒犻櫎鍚庡箍搴︿紭鍏堥亶鍘?/span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>           tree.BreadthFirst();<br><br>        }<br>        </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;"> printNode(BSTIntNode node)<br>        {<br>            Console.WriteLine(</span><span style="color: #000000;">"</span><span style="color: #000000;">璁塊棶鑺傜偣:{0}</span><span style="color: #000000;">"</span><span style="color: #000000;">, node.value);<br>        }</span></div> <br> <p>鍙互鐪嬪埌錛孋#鐨刣elegate鏈哄埗闈炲父鏈夎叮錛屽鏋滃湪java涓亹鎬曢渶瑕佺敤inner class鏉ュ疄鐜頒簡銆?br></p> <p><br></p><img src ="http://www.tkk7.com/killme2008/aggbug/108018.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/killme2008/" target="_blank">dennis</a> 2007-04-02 17:29 <a href="http://www.tkk7.com/killme2008/archive/2007/04/02/108018.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C#瀹炵幇鏍堝拰闃熷垪http://www.tkk7.com/killme2008/archive/2007/03/30/107409.htmldennisdennisFri, 30 Mar 2007 01:44:00 GMThttp://www.tkk7.com/killme2008/archive/2007/03/30/107409.htmlhttp://www.tkk7.com/killme2008/comments/107409.htmlhttp://www.tkk7.com/killme2008/archive/2007/03/30/107409.html#Feedback0http://www.tkk7.com/killme2008/comments/commentRss/107409.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/107409.htmlC#閾捐〃鐨勫疄鐜?/a>錛屽疄鐜版爤鍜岄槦鍒楁槗濡傚弽鎺屻?br />
鏍堬紝鍒╃敤鍗曞悜閾捐〃瀹炵幇錛?br />
publicabstractclass聽AbstractStack
聽聽聽聽{
聽聽聽聽聽聽聽聽
publicabstract聽Object聽Pop();
聽聽聽聽聽聽聽聽
publicabstractvoid聽Push(Object聽obj);
聽聽聽聽聽聽聽聽
publicabstractbool聽IsEmpty();
聽聽聽聽聽聽聽聽
publicabstract聽Object聽Top();
聽聽聽聽聽聽聽聽
publicabstractvoid聽Clear();
聽聽聽聽}

聽聽聽聽
publicclass聽Stack聽:聽AbstractStack
聽聽聽聽{
聽聽聽聽聽聽聽聽
private聽SList聽list;
聽聽聽聽聽聽聽聽
public聽Stack()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽list聽
=new聽SList();
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
publicoverridebool聽IsEmpty()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
return聽list.IsEmpty();
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
publicoverridevoid聽Push(Object聽obj)
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽list.Push(obj);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
publicoverrideobject聽Pop()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
return聽list.Pop();
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
publicoverrideobject聽Top()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
return聽list.getTail();
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
publicoverridevoid聽Clear()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽list.Clear();聽
聽聽聽聽聽聽聽聽}
聽聽聽聽}

闃熷垪鐨勫疄鐜幫紝閫氳繃鍙屽悜閾捐〃瀹炵幇錛屽浜庣幆褰㈡暟緇勭殑瀹炵幇璇峰弬鑰冦?a href="/killme2008/archive/2007/02/20/100239.html">鏁扮粍緇撴瀯涔嬫爤涓庨摼琛?/a>銆嬶細
publicinterface聽Queue
聽聽聽聽{
聽聽聽聽聽聽聽聽
bool聽IsEmpty();
聽聽聽聽聽聽聽聽
void聽Enqueue(Object聽obj);
聽聽聽聽聽聽聽聽Object聽Dequeue();
聽聽聽聽聽聽聽聽Object聽First();
聽聽聽聽}

聽聽聽聽
publicclass聽ListQueue:Queue
聽聽聽聽{
聽聽聽聽聽聽聽聽
private聽LinkedList聽list;
聽聽聽聽聽聽聽聽
public聽ListQueue()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽list聽
=new聽LinkedList();
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
publicbool聽IsEmpty()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
return聽list.IsEmpty();
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
publicvoid聽Enqueue(Object聽obj)
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽list.Push(obj);
聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
public聽Object聽Dequeue()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
return聽list.Shift();
聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽
public聽Object聽First()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
return聽list.getHead();
聽聽聽聽聽聽聽聽}
聽聽聽聽}



dennis 2007-03-30 09:44 鍙戣〃璇勮
]]>
C#瀹炵幇閾捐〃http://www.tkk7.com/killme2008/archive/2007/03/29/107261.htmldennisdennisThu, 29 Mar 2007 09:02:00 GMThttp://www.tkk7.com/killme2008/archive/2007/03/29/107261.htmlhttp://www.tkk7.com/killme2008/comments/107261.htmlhttp://www.tkk7.com/killme2008/archive/2007/03/29/107261.html#Feedback0http://www.tkk7.com/killme2008/comments/commentRss/107261.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/107261.html闃呰鍏ㄦ枃

dennis 2007-03-29 17:02 鍙戣〃璇勮
]]>
瀵筂arshalByRefObject鐨勮В閲?/title><link>http://www.tkk7.com/killme2008/archive/2007/03/28/107037.html</link><dc:creator>dennis</dc:creator><author>dennis</author><pubDate>Wed, 28 Mar 2007 09:55:00 GMT</pubDate><guid>http://www.tkk7.com/killme2008/archive/2007/03/28/107037.html</guid><wfw:comment>http://www.tkk7.com/killme2008/comments/107037.html</wfw:comment><comments>http://www.tkk7.com/killme2008/archive/2007/03/28/107037.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/killme2008/comments/commentRss/107037.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/killme2008/services/trackbacks/107037.html</trackback:ping><description><![CDATA[聽聽聽 浠婂ぉ鐪嬪埌涓孌典粙緇岰#瀹炵幇浠g悊妯″紡鐨勪唬鐮侊紝浣跨敤鍒頒簡<span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">銆傞偅涔?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鍒板簳鏄粈涔堜笢瑗垮憿錛熺畝鍗曟潵璁詫紝緇ф壙姝ょ被鐨勫璞?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鍙互璺ㄨ秺搴旂敤紼嬪簭鍩熻竟鐣岃寮曠敤錛岀敋鑷寵榪滅▼寮曠敤銆傝繙紼嬭皟鐢ㄦ椂錛屽皢浜х敓涓涓繙紼嬪璞″湪鏈湴鐨勯忔槑浠g悊錛岄氳繃姝や唬鐞嗘潵榪涜榪滅▼璋冪敤銆備竴綃囧緢濂界殑瑙i噴鏂囩珷錛屾潵鑷猦ttp://dudu.cnblogs.com/archive/2004/03/04/2182.html<br /><br /><br /></span><div id="1611111" class="postText"><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><b style=""><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">闂細</span></b><b style=""><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></b></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鎵撴壈涓涓嬶紝璇烽棶</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓殑</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">"Marshal"</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">搴旇鎬庢牱鐞嗚В錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p>聽</o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><b style=""><span style="font-family: 瀹嬩綋;">鍥炲</span></b><span style="font-family: 瀹嬩綋;">錛?/span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鎸夌収</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">package</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勬剰鎬濈悊瑙?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">鈥斺?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">褰撲竴涓璞¢渶瑕侀暱閫旇穻娑夊埌鍙︿竴涓幆澧冧腑鏃訛紝闇瑕佸皢鍏?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">marshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鎴愪竴涓彲浠ヤ紶杈撶殑褰㈡侊紙姣斿鍦?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">.NET Remoting</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓璞″皢琚墦鍖呮垚涓涓?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">serializable</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">瀹炰緥</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">鈥斺?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">榪欎釜</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ByRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">灝辨槸鎸?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">榪欑褰㈡侊級錛涘悓鐞嗭紝褰撴墦鍖呬互鍚庝紶杈撳埌鐩爣鍦扮偣錛岃繕瑕佹墽琛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">unmarshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勬搷浣滃皢鍏惰繕鍘熶負鍐呭瓨涓殑瀵硅薄銆傦細錛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US"><o:p>聽</o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><b style=""><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">闂細</span></b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">璋㈣阿錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏄笉鏄彲浠ヨ繖鏍風悊瑙o細瀵硅寮曠敤鐨勫璞¤繘琛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">Marshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">銆傚鏋滄寜鐓?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">package</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勬剰鎬濈悊瑙o紝閭?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">package</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勮繃紼嬫槸鎬庢牱鐨勶紵</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MSDN</span></b><b><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓婅繖鏍瘋錛?/span></b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span></b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"></span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏄氳繃浣跨敤</span><span style="font-size: 10pt; color: red; font-family: 瀹嬩綋;">浠g悊</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">浜ゆ崲娑堟伅鏉ヨ法搴旂敤紼嬪簭鍩熻竟鐣岃繘琛岄氳鐨勫璞$殑鍩虹被</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">.<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span></b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"></span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">瀵硅薄鍦ㄦ湰鍦板簲鐢ㄧ▼搴忓煙鐨勮竟鐣屽唴鍙洿鎺ヨ闂傝繙紼嬪簲鐢ㄧ▼搴忓煙涓殑搴旂敤紼嬪簭棣栨璁塊棶</span><b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span></b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"></span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏃訛紝浼氬悜璇ヨ繙紼嬪簲鐢ㄧ▼搴忎紶閫?/span><span style="font-size: 10pt; color: red; font-family: 瀹嬩綋;">浠g悊</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">銆傚璇ヤ唬鐞嗗悗闈㈢殑璋冪敤灝嗗皝閫佸洖椹葷暀鍦ㄦ湰鍦板簲鐢ㄧ▼搴忓煙涓殑瀵硅薄銆?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鍦?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">Marshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓紝涓婇潰鎵璇寸殑浠g悊鏄粈涔堬紵鏈変粈涔堢敤錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MSDN</span></b><b><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓婅繕璁插埌錛?/span></b><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">褰撹法搴旂敤紼嬪簭鍩熻竟鐣屼嬌鐢ㄧ被鍨嬫椂錛岀被鍨嬪繀欏繪槸浠?/span><span style="font-size: 10pt; color: black; font-family: Verdana;"><b><span lang="EN-US">MarshalByRefObject</span></b><span lang="EN-US"></span></span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">緇ф壙鐨勶紝鑰屼笖鐢變簬瀵硅薄鐨勬垚鍛樺湪鍒涘緩瀹冧滑鐨勫簲鐢ㄧ▼搴忓煙涔嬪鏃犳硶浣跨敤錛屾墍浠?/span><span style="font-size: 10pt; color: red; font-family: 瀹嬩綋;">涓嶅緱澶嶅埗瀵硅薄鐨勭姸鎬?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">銆?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏃㈢劧瀵硅薄鐨勭姸鎬佷笉鑳戒紶閫掕繃鍘伙紝閭d紶閫掕繖涓璞″張鏈変綍鎰忎箟錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">絎竴嬈″幓鐞嗚В</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛屾湁鐨勯棶棰樺彲鑳芥彁鐨勬瘮杈冭偆嫻咃紝璇鋒偍鎸囩偣銆?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><o:p>聽</o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><b style=""><span style="font-family: 瀹嬩綋;">鍥炲錛?/span></b><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt;"><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏄墍鏈夊彲浠ュ湪</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">AppDomain</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">杈圭晫澶栭儴璁塊棶鐨勫璞$殑鍩虹被錛岄噸蹇冧笉鏄?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">marshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛岃屾槸</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">object</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛屽嵆</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">object that could be marshaled by reference</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛屼篃灝辨槸鍙互閫氳繃</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">Ref</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛堝疄闄呬笂鏄?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">瀵硅薄錛夌殑鏈哄埗榪涜</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">鈥?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">灝侀?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">鈥?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">MSDN</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓枃鐗堝</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">marshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓璇嶇殑緲昏瘧錛夌殑瀵硅薄銆傚皝閫佺殑琛屼負鏄敱浠g悊鏉ュ仛鐨勶紝榪欓噷璇寸殑浠g悊灝辨槸鎴戞枃绔犱腑璁茶繃鐨?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">.NET Remoting</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勭湡瀹炰唬鐞嗭紙鍗?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">RemotingProxy</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛夈傜湡瀹炰唬鐞嗕笉鏄湁涓涓?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">Invoke()</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏂規(guī)硶鍚楋紵褰撲綘閫忚繃瀵逛竴涓?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">MBRO</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勯忔槑浠g悊璁塊棶璇ュ璞$殑鏂規(guī)硶鏃訛紝閫忔槑浠g悊灝嗘妸鍩轟簬鍫嗘爤鐨勬柟娉曡皟鐢ㄨ漿鎹負鏂規(guī)硶璋冪敤娑堟伅錛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">IMethodCallMessage</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛夊茍杞彂緇欑湡瀹炰唬鐞嗭紙鍦?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">Remoting</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勫満鍚堜腑涔熷嵆</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">RemotingProxy</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛夛紝鑰?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">RemotingProxy</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勪換鍔″氨鏄妸瀵硅薄灝侀佸茍榪炲悓鏂規(guī)硶璋冪敤娑堟伅涓璧瘋漿鍙戠粰榪滅▼搴旂敤紼嬪簭鍩燂紱鍒拌揪鐩殑鍦頒互鍚庣殑鎿嶄綔綾諱技錛氳繙紼嬪簲鐢ㄧ▼搴忓煙涓殑鐩戝惉鏂瑰綋鏀跺埌鍙戞潵鐨勬柟娉曡皟鐢ㄦ秷鎭椂錛屽厛鍙栧嚭灝侀佸ソ鐨?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛堣繖涓璞¢噷闈繚瀛樼潃鍙戞潵璋冪敤鐨勯偅涓璞★紒錛夛紝灝嗗叾緇撳皝錛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">unmarshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛変負鏈湴鐨勫璞★紝騫惰幏寰楀叾閫忔槑浠g悊錛岀劧鍚庡氨鍙互鎶婃柟娉曡皟鐢ㄦ秷鎭湪杞崲鍥炲熀浜庡爢鏍堢殑璋冪敤鍙戦佺粰榪欎釜瀵硅薄銆?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">瀵硅薄鏄湪鏈湴緇存姢鐨勶紝浣嗘槸鏂規(guī)硶鍙互鍦ㄨ繙紼嬭皟鐢ㄣ備綘姣斿璇翠竴涓?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">web</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">搴旂敤紼嬪簭錛屼綘鏄氳繃鏈湴鐨勬祻瑙堝櫒榪滅▼璁塊棶榪欎釜搴旂敤紼嬪簭錛屼絾鏄簲鐢ㄧ▼搴忕殑鐘舵佷笉浼氱敱浣犵殑嫻忚鍣ㄨ礋璐o紙鎵浠ヤ綘鍙槸鍦ㄨ闂繖涓簲鐢ㄧ▼搴忔彁渚涚粰浣犵殑鍔熻兘鑰屽凡錛屼綘騫舵病浜庢嫢鏈夊簲鐢ㄧ▼搴忔湰韜紝鍖呮嫭鍏舵墍鏈夋暟鎹級錛屼綘鍙槸鍙戦佷竴涓釜鐨勮姹傦紝鏈嶅姟鍣ㄥ憡璇変綘澶勭悊鐨勭粨鏋溿傚湪</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">Remoting</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓? 涔熸槸涓鏍鳳紝褰撲綘鑾峰緱涓涓繙紼嬪璞$殑鏃跺欙紝浣犲疄闄呬笂鍙嫢鏈夊榪欎釜瀵硅薄鐨勪竴涓繙紼嬪紩鐢紝铏界劧浣犲彲浠ヨ皟鐢ㄥ畠鐨勬柟娉曪紝浣嗗疄闄呬笂榪欎簺鎿嶄綔閮芥槸鍙戠敓鍦ㄨ繙紼嬬殑錛堝氨鏄墠闈? 璁茶繃鐨勮繃紼嬶級錛屼綘鍙槸浼犲叆浜嗕竴浜涘弬鏁幫紝寰楀埌浜嗕竴涓粨鏋滐紝浣嗗璞$殑鐘舵佽繕鏄湪榪滅▼緇存姢鐨勶紙鎹㈠彞璇濊錛屽璞℃湰韜篃灝辨槸瀵硅薄鐨勬墍鏈夌姸鎬佸茍娌℃湁琚線榪斾紶閫掞紝浼犻掔殑 鍙槸浼犲叆浼犲嚭鐨勫弬鏁?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">鈥斺?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">褰撶劧錛屽鏋滃弬鏁版槸涓涓?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">MBRO</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勮瘽錛岃繕鏄紶閫掑璞¤灝侀佺殑寮曠敤錛夈?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 21pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涔熻搴旇緇欎綘鍑嗗涓涓ソ鐞嗚В鐨勪緥瀛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">鈥︹?/span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">浣犲氨浼氳眮鐒跺紑鏈椾簡銆傦細錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><o:p>聽</o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><b style=""><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">闂細</span></b><b style=""><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></b></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鎴戣繖鏍風殑鐞嗚В瀵逛笉瀵癸紵</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓鑸殑瀵硅薄涓庝粠</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">緇ф壙鐨勫璞″尯鍒槸錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">涓鑸殑瀵硅薄鍙兘鍦ㄦ湰鍦板簲鐢ㄧ▼搴忓煙涔嬪唴琚紩鐢紝鑰?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">MarshalByRefObject</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">瀵硅薄鍙互璺ㄨ秺搴旂敤紼嬪簭鍩熻竟鐣岃寮曠敤錛岀敋鑷寵榪滅▼寮曠敤銆?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span lang="EN-US"><o:p>聽</o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><b style=""><span style="font-family: 瀹嬩綋;">鍥炲</span></b><span style="font-family: 瀹嬩綋;">錛?/span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">Exactly! </span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">褰撳璞¤法鍑?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">AppDomain</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">杈圭晫鐨勬椂鍊欙紝瀹為檯涓婂彧鏄畠鐨勪竴涓紩鐢紙</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛夈備綘姣斿璇村惂錛?/span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">public class LocalObject<br />{</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">聽 public void CallRemoteObject(MarshalByRefObject mbro)<br />聽 {<br />聽聽聽 Console.WriteLine(mbro.ToString());</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">聽 }<br />}</span><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"><span style="font-size: 10pt; color: black; font-family: Verdana;" lang="EN-US">聽<o:p></o:p></span></p><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">褰撲紶鍏ヤ竴涓湪鏈湴鍒涘緩鐨?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">mbro</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">瀵硅薄鏃訛紝</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ToString()</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏂規(guī)硶鏄洿鎺ュ彂閫佺粰瀵硅薄鐨勶紱鑰屽綋</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">mbro</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鏄氳繃</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">Remoting</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鍒涘緩鐨勮繙紼嬪璞$殑璇濓紝瀹為檯涓婂畠鍙槸涓涓寘鍚湁宸茬粡</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">marshal</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">濂界殑</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐨勯忔槑浠g悊錛?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">ObjRef</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">閲岄潰鏈変粈涔堬紵瀵硅薄瀹炰緥鐨?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">URI</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛佹墍浠ュ綋浣犺皟鐢ㄨ繖涓繙紼嬪璞℃椂錛岀浉褰撲簬鍚戣繖涓繙紼嬬鍙o紙</span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">tcp://remoteServer/xxxx.rem</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">錛夊彂閫佹柟娉曡皟鐢ㄦ秷鎭屽凡銆傚彧涓嶈繃閫忔槑浠g悊闅愯棌浜嗗璞′綅緗殑姒傚康錛岃?/span><span style="font-size: 10pt; color: black; font-family: Arial;" lang="EN-US">RemotingProxy</span><span style="font-size: 10pt; color: black; font-family: 瀹嬩綋;">鐪熷疄浠g悊鍒欐槸瀹為檯涓婂鐞嗚繙紼嬫柟娉曡皟鐢ㄥ拰瀵硅薄灝侀佺殑涓灑瀵硅薄銆?/span></div><br /><img src ="http://www.tkk7.com/killme2008/aggbug/107037.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/killme2008/" target="_blank">dennis</a> 2007-03-28 17:55 <a href="http://www.tkk7.com/killme2008/archive/2007/03/28/107037.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浣撻獙rails1.2鐨凴EST椋庢牸http://www.tkk7.com/killme2008/archive/2007/03/20/105083.htmldennisdennisTue, 20 Mar 2007 12:04:00 GMThttp://www.tkk7.com/killme2008/archive/2007/03/20/105083.htmlhttp://www.tkk7.com/killme2008/comments/105083.htmlhttp://www.tkk7.com/killme2008/archive/2007/03/20/105083.html#Feedback0http://www.tkk7.com/killme2008/comments/commentRss/105083.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/105083.html瀛︿範REST銆嬪浜庡垵嬈℃帴瑙EST鐨勪漢鏉ヨ鏇村ソ鐞嗚В銆?p>聽聽聽 鎴戜滑鍦?Web 搴旂敤涓鐞嗘潵鑷鎴風鐨勮姹傛椂錛岄氬父鍙冭檻 GET 鍜?POST 榪欎袱縐?HTTP 璇鋒眰鏂規(guī)硶銆傚疄闄呬笂錛孒TTP 榪樻湁 HEAD銆丳UT銆丏ELETE 絳夎姹傛柟娉曘傝屽湪 REST 鏋舵瀯涓紝鐢ㄤ笉鍚岀殑 HTTP 璇鋒眰鏂規(guī)硶鏉ュ鐞嗗璧勬簮鐨? CRUD錛堝垱寤恒佽鍙栥佹洿鏂板拰鍒犻櫎錛夋搷浣滐細

  • POST: 鍒涘緩
  • GET: 璇誨彇
  • PUT: 鏇存柊
  • DELETE: 鍒犻櫎

緇忚繃榪欐牱鐨勪竴鐣墿灞曪紝鎴戜滑瀵逛竴涓祫婧愮殑 CRUD 鎿嶄綔灝卞彲浠ラ氳繃鍚屼竴涓?URI 瀹屾垚浜嗐傞渶瑕佹敞鎰忕殑鏄疪EST鐨勬牳蹇冨氨鏄祫婧愶紙resources錛夎繖涓蹇點傛垜浠墍璇寸殑webservice鏄竴縐嶅緩绔嬪湪http鍗忚涓婄殑榪滅▼璋冪敤錛岃孯EST灝辨槸鎶婅繙紼嬭皟鐢ㄦ娊璞℃垚瀵硅繙紼嬭祫婧愮殑CRUD鐨勬搷浣滐紝姝eソ鍙互鐢℉TTP鐨凱UT GET POST DELETE鏉ュ搴旓紝鑰屼笉鏄噸鏂板彂鏄庝竴涓崗璁紙姣斿soap錛岀畝鍗曞璞¤闂崗璁級銆俁EST涓嶢JAX鐨勬祦琛岋紝鐢氳嚦榪滆嚦璁捐妯″紡鐨勫叴璧鳳紝閮藉厖鍒嗚鏄庝竴涓幇璞★紝鍦ㄦ垚鐔熺殑搴旂敤鐨勫熀紜涓婂垱鏂拌岄潪鎵╁睍鍑哄鏉傛墍璋撯滃垱鏂版р濇灦鏋勫湪杞歡琛屼笟鏄洿涓哄彲闈犮?/p>

聽聽聽 瀹炴垬浣撻獙REST鍙互浠嶪BM Developer鐨勮繖綃囨枃绔犲紑濮嬨?a >璺ㄨ秺杈圭晫錛歊est On Rails銆嬨傝繖綃囨枃绔犳槸鍦≧ails1.2鍙戝竷涔嬪墠鍑烘潵鐨勶紝鏈変簺鍦版柟宸茬粡鍙互淇敼鐨勬洿綆緇冿紝鎴戞妸鎴戠殑緇冧範榪囩▼璁板綍涓嬶紝騫舵坊鍔犱簡C#璋冪敤REST椋庢牸web service鐨勪緥瀛愩?/p>

聽聽聽 棣栧厛錛屼綘鐨勬満鍣ㄤ笂闇瑕佸畨瑁卹ails1.2錛屽茍涓斿亣璁句綘瀵箁ails鏈夊熀鏈殑浜嗚В錛屽緩绔嬩竴涓簲鐢ㄥ彨service,鍛戒護琛屾墽琛岋細

聽聽
聽rails聽service

rails鑷姩甯綘鐢熸垚搴旂敤鐨勫熀鏈粨鏋勫拰鍩虹浠g爜錛岀劧鍚庣紪杈慶onfig涓嬮潰鐨刣atabase.yml璁劇疆鏁版嵁搴擄紝騫跺緩绔嬫暟鎹畇ervice_development錛屾垜鐢ㄧ殑鏄痬ysql鏁版嵁搴撱?/p>

create.bmp

鍒╃敤rails1.2鏂扮殑scaffold鍛戒護錛?/p>

ruby聽script/generate聽scaffold_resource聽person

榪欎釜鍛戒護灝嗚嚜鍔ㄧ敓鎴怉ctiveRecord,Controller浠ュ強View錛屽湪\app\models涓嬪彲浠ュ彂鐜拌嚜鍔ㄧ敓鎴愮殑Model鈥斺攑erson.rb銆傛墦寮service\db\migrate涓嬮潰鐨?01_create_people.rb錛岀紪杈戝涓嬶細

class聽CreatePeople聽<聽ActiveRecord::Migration
聽聽def聽self
.up
聽聽聽聽create_table聽
:people聽do|t|
聽聽聽聽聽t
.column聽:first_name,:string,:limit聽=>40
聽聽聽聽聽t
.column聽:last_name,:string,:limit聽=>40
聽聽聽聽聽t
.column聽:email,:string,:limit聽=>40
聽聽聽聽聽t
.column聽:phone,:string,:limit聽=>15
聽聽聽聽end
聽聽end

聽聽def聽self
.down
聽聽聽聽drop_table聽
:people
聽聽end
end

鍒╃敤rake鍛戒護鑷姩寤鴻〃錛屾墽琛?
rake聽db:migrate
rails榛樿琛ㄦ槑鏄疢odel鐨勫鏁板艦寮忥紝涔熷氨鏄繖閲屽皢鑷姩寤虹珛涓寮犲悕鍙玴eople鐨勮〃銆?br />
OK錛屼竴鍒囧氨緇紝鍚姩WEBric錛岃闂甴ttp://localhost:3000/people錛屾樉紺猴細
rest1.bmp

scaffold宸茬粡甯垜浠嚜鍔ㄧ敓鎴愪簡涓涓person璧勬簮鐨刢rud鎿嶄綔錛屽鍒犳敼鏌ヤ技涔庤窡浼犵粺鐨剅ails娌℃湁浠涔堜笉鍚屽槢銆傚鏋滀綘璁ょ湡瑙傚療鍦ㄦ搷浣滆繃紼嬩腑URL鐨勫彉鍖栨儏鍐靛氨浼氬彂鐜板湪鎿嶄綔榪囩▼涓璘RL鐨勫彉鍖栧緢灝忥紝鑰屼笖涓庝紶緇焤ails鐨刄RL璺敱鐩告瘮錛岀渷鍘諱簡action鍚嶇О銆傚嚭鐜扮殑鍙樺寲鍦?people銆?people/1銆?people/1;edit鍜?people/new榪欏嚑涓箣涓傚湪/people鐨刄RL涓殣钘忚繖鍙兘鏄痟ttp鐨凱OST鎴栬匞ET鐨勬柟娉曪紝鍓嶈呯敤浜巆reate鎿嶄綔錛岃孏ET鐢ㄤ簬show鎿嶄綔錛屽叿浣撲綘鍙互鏌ョ湅app/controllers/鐩綍涓嬬殑PeopleController綾伙紝姣忎釜action鐨勫墠闈㈤兘娉ㄩ噴浜嗗畠浠皢瀵瑰簲鍝釜HTTP鏂規(guī)硶銆傝?people/1涓殑1鎸囩殑鏄祫婧愮殑鏍囧織絎︼紝姣斿榪欓噷person鐨刬d錛岄氳繃榪欎釜ID鏉ヨ繘琛岃祫婧愮殑鎿嶄綔錛屼篃璁告槸PUT鏂規(guī)硶錛堟洿鏂幫級錛屼篃璁告槸DELETE鏂規(guī)硶錛堝垹闄わ級銆俽ails瀹炵幇PUT鍜孌elete鏄氳繃闅愯棌瀛楁鏉ュ疄鐜扮殑錛屾煡鐪嬬紪杈戦〉闈㈢敓鎴愮殑html婧愪唬鐮侊紝浣犲皢鍙戠幇涓涓猒method鐨勯殣钘忓瓧孌碉紝鍊間負PUT銆傝屽彟澶栦袱涓猆RL錛?people/1;edit鍜?people/new錛岃繖涓や釜騫墮潪涓ユ牸鎰忎箟涓婄殑RESTful URL錛屽畠浠彧鏄負浜嗘樉紺虹敤錛屾樉紺篺orm琛ㄥ崟鐢ㄤ簬鏂板緩鍜岀紪杈戙傚叧浜嶳ESTful椋庢牸鐨刄RL鐨勮緇嗚璁鴻瑙併奟ESTfull Rails Development銆嬫枃妗c?br />
聽聽聽 濡傛灉rails鍙槸榪欐牱鐨勫▉鍔涳紝閭e氨鏈夌偣灝忔彁澶у仛浜嗭紝鐪嬬湅PeopleController鐨剆how action錛屽畠瀵瑰簲浜巋ttp鐨凣ET璇鋒眰錛岃繑鍥瀙eople鍒楄〃錛?br />
#聽GET聽/people/1
聽聽#聽GET聽/people/1.xml

聽聽def聽show
聽聽聽聽
@person=聽Person.find(params[:id])

聽聽聽聽respond_to聽
do|format|
聽聽聽聽聽聽
format.html聽#聽show.rhtml
聽聽聽聽聽聽format.xml聽聽{聽render聽:xml聽=>@person.to_xml聽}
聽聽聽聽end
聽聽end

紲炲鐨勫湴鏂瑰湪respond_to鏂規(guī)硶涓紝鏍規(guī)嵁璇鋒眰鏂囦歡綾誨瀷錛坔ttp Header鐨凜ontentType錛夛紝鏄劇ずhtml鏍煎紡錛屾垨鑰厁ml鏍煎紡錛堣繕鏈夊叾浠栨敮鎸侊紝姣斿json銆丷SS銆丄tom絳夌瓑錛夈傛瘮濡備綘娣誨姞浜嗕竴涓猵erson,閫氳繃http://localhost:3000/people/1璁塊棶錛屽彲浠ョ湅鍒拌繖涓漢鍛樼殑鍏蜂綋淇℃伅錛?br />rest2.bmp
鎴戜滑鍐嶉氳繃http://localhost:3000/people/3.xml璁塊棶鐪嬪埌鐨勫嵈鏄竴涓獂ml鏂囦歡錛?br />
rest3.bmp

涓嶄粎濡傛錛屾垜浠篃鍙互閫氳繃鍏朵粬璇█緙栧啓瀹㈡埛绔潵璋冪敤http://localhost:3000/people/1榪欎釜url錛屾參鐫錛岃繖涓嶆鏄痺eb service榪滅▼璋冪敤鍚楋紵娌¢敊錛孯EST椋庢牸鐨剋eb service鐩告瘮浜巜sdl銆乻oap瀹氫箟鐨剋eb service綆鍗曚簡澶澶錛屼篃鏇村姞瀹炵敤銆傛垜浠潵緙栧啓涓涓猨ava綾昏皟鐢╤ttp://localhost:3000/people鑾峰緱鎵鏈夌殑浜哄憳鍒楄〃錛?br />
package聽example;

import聽java.io.BufferedReader;
import聽java.io.InputStreamReader;
import聽java.io.OutputStreamWriter;
import聽java.net.HttpURLConnection;
import聽java.net.URL;
import聽java.net.URLConnection;

publicclass聽RESTDemo聽{

聽聽聽聽
/**
聽聽聽聽聽*聽
@param聽args
聽聽聽聽聽
*/
聽聽聽聽
publicstaticvoid聽main(String[]聽args)聽{
聽聽聽聽聽聽聽聽RESTDemo聽restDemo聽
=new聽RESTDemo();
聽聽聽聽聽聽聽聽聽聽聽聽restDemo.get();
聽聽聽聽聽聽聽聽
聽聽聽聽}

聽聽聽聽
void聽get()聽{

聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽URL聽url聽
=new聽URL("http://localhost:3000/people");
聽聽聽聽聽聽聽聽聽聽聽聽URLConnection聽urlConnection聽
=聽url.openConnection();
聽聽聽聽聽聽聽聽聽聽聽聽urlConnection.setRequestProperty(
"accept",聽"text/xml");
聽聽聽聽聽聽聽聽聽聽聽聽BufferedReader聽in聽
=new聽BufferedReader(new聽InputStreamReader(
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽urlConnection.getInputStream()));
聽聽聽聽聽聽聽聽聽聽聽聽String聽str;

聽聽聽聽聽聽聽聽聽聽聽聽
while聽((str聽=聽in.readLine())聽!=null)聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(str);
聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽聽聽聽in.close();
聽聽聽聽聽聽聽聽}聽
catch聽(Exception聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(e);
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

鎴戜滑娌℃湁浠涔堟湇鍔$鎺ュ彛class錛屾垜浠篃涓嶇敤鐢熸垚浠涔坰tub錛屾垜浠皟鐢ㄧ殑鏈甯歌鏈甯歌鐨刪ttp鍗忚錛屽彂閫佺殑鏄粯璁ょ殑GET璇鋒眰錛宺ails鑷姩灝嗚璇鋒眰杞彂緇檚how action銆傛敞鎰忥紝鎴戜滑榪欓噷鎶?span style="color: rgb(0, 0, 0);">accept璁劇疆涓簍ext/xml錛宻how鏂規(guī)硶鏍規(guī)嵁姝ゆ牸寮忚繑鍥炰竴涓獂ml鏂囨。錛屼笅闈㈡槸杈撳嚭錛?br />
<?xml聽version="1.0"聽encoding="UTF-8"?>
<people>
聽聽
<person>
聽聽聽聽
<email>killme2008@gmail.com</email>
聽聽聽聽
<first-name>dennis</first-name>
聽聽聽聽
<id聽type="integer">1</id>
聽聽聽聽
<last-name>zane</last-name>
聽聽聽聽
<phone>1355XXXXXXX</phone>
聽聽
</person>
</people>

濡傛灉浠呬粎鏄疓ET璇鋒眰鏄笉澶熺殑錛屾垜浠榪囷紝鎶婅繙紼嬭皟鐢ㄦ娊璞℃垚瀵硅繙紼嬭祫婧愮殑CRUD鎿嶄綔錛岄偅涔堝浣昪reate銆乨elete鍜寀pdate榪滅▼璧勬簮鍛紵鍚屾牱寰堢畝鍗曪紝姣斿鎴戜滑閫氳繃C#榪滅▼璋冪敤錛屽垱寤轟竴涓柊person錛岃繕璁扮殑鎴戣榪囧悧錛?people鍙互鏄疨OST璇鋒眰錛屼粬灝嗚皟鐢≒eopleController鐨刢reate鏂規(guī)硶錛?br />
using聽System;
using聽System.Net;
using聽System.IO;
using聽System.Text;
namespace聽demo
{
聽聽聽聽
class聽RESTDemo
聽聽聽聽{
聽聽聽聽聽聽聽聽
staticvoid聽Main(string[]聽args)
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
string聽xmlText聽="<person>聽"+"<first-name>jordan</first-name>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+"<last-name>jordan</last-name>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+"<email>maggie@tate.com</email>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+"<phone>010-XXXXXXXX</phone>"+"</person>";
聽聽聽聽聽聽聽聽聽聽聽聽Uri聽address聽
=new聽Uri("http://localhost:3000/people");聽聽
聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽
//聽鍒涘緩web璇鋒眰
聽聽聽聽聽聽聽聽聽聽聽聽HttpWebRequest聽request聽=聽WebRequest.Create(address)聽as聽HttpWebRequest;聽聽
聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽
//聽璁劇疆璇鋒眰綾誨瀷涓篜OST錛岃皟鐢╟reate聽action
聽聽聽聽聽聽聽聽聽聽聽聽request.Method聽="POST";聽聽
聽聽聽聽聽聽聽聽聽聽聽聽request.ContentType聽
="application/xml";

聽聽聽聽聽聽聽聽聽聽聽聽
byte[]聽xmlBytes聽=聽Encoding.ASCII.GetBytes(xmlText);

聽聽聽聽聽聽聽聽聽聽聽聽
using聽(Stream聽reqStream聽=聽request.GetRequestStream())
聽聽聽聽聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽reqStream.Write(xmlBytes,聽
0,聽xmlBytes.Length);
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽聽聽聽聽
using聽(WebResponse聽wr聽=聽request.GetResponse())
聽聽聽聽聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽wr.
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
//鎵撳嵃榪斿洖鐨刪ttp澶?/span>
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(wr.Headers.ToString());
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽聽}聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽聽聽聽

聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

鎵ц姝ょ▼搴忥紝鍒鋒柊http://localhost:3000/people錛屽彲浠ョ湅鍒版柊寤轟簡涓涓漢鍛樺涓?br />
rest4.bmp

濂芥瀬浜嗭紝GET鍜孭OST閮芥湁浜嗭紝閭d箞PUT瀵瑰簲鐨勬洿鏂板拰DELETE瀵瑰簲鐨勫垹闄ゅ張璇ユ庝箞鍋氬憿錛屽敮涓鐨勫尯鍒氨鏄緗姹傜被鍨嬩笉鍚岃屽凡錛宩ava璋冪敤濡備笅錛?br />
聽聽聽聽void聽put()聽{
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽String聽xmlText聽
="<person>聽"+"<first-name>test</first-name>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+"<last-name>test</last-name>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+"<email>maggie@tate.com</email>"
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
+"<phone>010-XXXXXXXX</phone>"+"</person>";

聽聽聽聽聽聽聽聽聽聽聽聽URL聽url聽
=new聽URL("http://localhost:3000/people/1");
聽聽聽聽聽聽聽聽聽聽聽聽HttpURLConnection聽conn聽
=聽(HttpURLConnection)聽url.openConnection();
聽聽聽聽聽聽聽聽聽聽聽聽conn.setDoOutput(
true);
聽聽聽聽聽聽聽聽聽聽聽 //璁劇疆璇鋒眰涓篜UT
聽聽聽聽聽聽聽聽聽聽聽聽conn.setRequestMethod(
"PUT");
聽聽聽聽聽聽聽聽聽聽聽聽conn.setRequestProperty(
"Content-Type",聽"text/xml");
聽聽聽聽聽聽聽聽聽聽聽聽OutputStreamWriter聽wr聽
=new聽OutputStreamWriter(conn
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽.getOutputStream());
聽聽聽聽聽聽聽聽聽聽聽聽wr.write(xmlText);
聽聽聽聽聽聽聽聽聽聽聽聽wr.flush();
聽聽聽聽聽聽聽聽聽聽聽聽wr.close();
聽聽聽聽聽聽聽聽}聽
catch聽(Exception聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Error"+聽e);
聽聽聽聽聽聽聽聽}
聽聽聽聽}

聽聽聽聽
void聽delete()聽{
聽聽聽聽聽聽聽聽
try聽{
聽聽聽聽聽聽聽聽聽聽聽聽URL聽url聽
=new聽URL("http://localhost:3000/people/2");
聽聽聽聽聽聽聽聽聽聽聽聽HttpURLConnection聽conn聽
=聽(HttpURLConnection)聽url.openConnection();
聽聽聽聽聽聽聽聽聽聽聽聽conn.setDoOutput(
true);
聽聽聽聽聽聽聽聽聽聽聽 //璁劇疆璇鋒眰涓篋ELETE
聽聽聽聽聽聽聽聽聽聽聽聽conn.setRequestMethod(
"DELETE");
聽聽聽聽聽聽聽聽聽聽聽聽conn.setRequestProperty(
"Content-Type",聽"text/xml");
聽聽聽聽聽聽聽聽聽聽聽聽
if(conn.getResponseCode()==200)
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"鍒犻櫎鎴愬姛錛?/span>");
聽聽聽聽聽聽聽聽}
catch聽(Exception聽e)聽{
聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(
"Error"+聽e);
聽聽聽聽聽聽聽聽}
聽聽聽聽}

榪欓噷鐨刾ut鏂規(guī)硶灝嗙涓涓漢鍛樼殑鍚嶅瓧鏀逛簡錛岃宒elete鏂規(guī)硶騫茶剢灝嗗垰鎵岰#娣誨姞鐨勪漢鍛樺垹闄ゆ帀銆傚紓鏋勭郴緇熺殑榪滅▼璋冪敤鍙樼殑濡傛綆鍗曞緢杞繪澗錛屾妸浠涔圗JB銆丆ORBA銆丼OAP緇熺粺蹇樻帀鍚с傛兂璞¤繖鏍風殑鍦烘櫙錛屾墍鏈夌殑緗戠珯閮芥彁渚汻EST椋庢牸鐨凙PI錛岃繖涓笘鐣屽皢鏄粈涔堟ā鏍鳳紵

聽聽聽 REST甯︽潵鐨勪笉浠呬粎鏄痺eb service鐨勬敼鍙橈紝瀵筂VC鏋舵瀯鍚屾牱鍏鋒湁寰堥噸瑕佺殑鎰忎箟錛岃繃鍘繪垜浠殑澶嶇敤閫氬父鍦∕ODEL灞傦紝鎴戜滑涓鐩村笇鏈涘鐢ㄤ笟鍔¢昏緫灞傦紝鍗存病鏈夋兂榪囨槸鍚﹁兘澶嶇敤Controller鐢氳嚦View鍛紵REST涓烘垜浠彁渚涗簡鍙兘錛屾瘮濡備互涓涓緢緇忓父琚彁鍒扮殑渚嬪瓙鏉ヨ錛岀敤鎴峰姞鍏ユ煇涓湀瀛愯繖涓搷浣滆窡鍦堝瓙鐨勭鐞嗗憳灝嗙敤鎴峰姞鍏ュ湀瀛愮殑鎿嶄綔鏄竴鏍鳳紝浣嗘槸鎿嶄綔鎴愬姛鍚庣殑璺寵漿鏄劇ず鐨勯〉闈篃璁鎬笉鍚岋紝榪囧幓涔熻鎴戜滑鏄氳繃鍐欎袱涓笉鍚岀殑Action鏉ュ疄鐜幫紝鑰岀幇鍦紝鍚屼竴涓狝ction錛堝姞鍏ュ湀瀛愯繖涓搷浣滐級鍙礋璐e彂閫佹暟鎹紙XML鏍煎紡鐨勬枃。锛夊Q岃岄〉闈㈢殑灞曠ず灝嗙暀緇欏鎴風鍘婚夋嫨錛屼粠鑰屽鐢ㄤ簡Controller錛屽噺灝戜簡Action鍜孷iew灞傜殑浠g爜閲忋傝繘涓姝ワ紝璇蜂綘鎯寵薄錛孯EST涓嶢JAX鐨勬妧鏈粨鍚堜駭鐢熷涔堟湁瓚g殑鐢婚潰銆?b>REST浠呯敤浜庢彁渚涙暟鎹?/b>錛屽睍鐜版洿澶氱殑浜ょ粰浜嗗鎴風銆?br />
聽聽聽 鏈枃浠呬粎鏄垜鎺ヨЕREST榪欎袱澶╃殑瀛︿範鎬葷粨錛屽浜嶳EST鐨勫簲鐢ㄦ墠鍒氬垰璧鋒錛岄渶瑕佹洿澶氱殑鎺㈣鍜屽疄璺點傚叾瀹瀓ava瀹炵幇REST涔熸槸鐩稿綋綆鍗曠殑錛宻ervlet鏈韓灝辨槸寰堝ソ鐨勬ā鍨嬶紝鎭愭曟病鏈夊浜烘敞鎰忓埌HttpServlet綾諱腑鐨刣oPut鍜宒oDelete鏂規(guī)硶錛屾垜浠繃鍘誨お寮鴻皟GET鍜孭OST錛屽弽鑰屽拷瑙嗕簡PUT鍜孌ELETE鍙兘甯︽潵鐨勬敼鍙樸俲ava寮婧愪笘鐣屼腑宸茬粡鏈変簡REST椋庢牸鐨勬鏋訛紝姣斿cetia4錛?/a>榪欐槸涓涓猻ervlet-base鐨凴EST妗嗘灦錛屽肩殑鍏蟲敞銆?br />

dennis 2007-03-20 20:04 鍙戣〃璇勮
]]>
浣跨敤 HttpWebRequest 鍚戠綉绔欐彁浜ゆ暟鎹?/title><link>http://www.tkk7.com/killme2008/archive/2007/03/20/105023.html</link><dc:creator>dennis</dc:creator><author>dennis</author><pubDate>Tue, 20 Mar 2007 08:32:00 GMT</pubDate><guid>http://www.tkk7.com/killme2008/archive/2007/03/20/105023.html</guid><wfw:comment>http://www.tkk7.com/killme2008/comments/105023.html</wfw:comment><comments>http://www.tkk7.com/killme2008/archive/2007/03/20/105023.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/killme2008/comments/commentRss/105023.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/killme2008/services/trackbacks/105023.html</trackback:ping><description><![CDATA[ <div id="6616616" class="postTitle"> <a id="viewpost1_TitleUrl" class="postTitle2" >杞嚜錛歨ttp://www.cnblogs.com/webman/archive/2006/11/17/564106.html<br /></a> </div> HttpWebRequest聽鏄?net聽鍩虹被搴撲腑鐨勪竴涓被錛屽湪鍛藉悕絀洪棿聽System.Net聽涓嬮潰錛岀敤鏉ヤ嬌鐢ㄦ埛閫氳繃聽HTTP聽鍗忚鍜屾湇鍔″櫒浜や簰銆偮?br /><br />HttpWebRequest聽瀵孤燞TTP聽鍗忚榪涜浜嗗畬鏁寸殑灝佽錛屽聽HTTP聽鍗忚涓殑聽Header,聽Content,聽Cookie聽閮藉仛浜嗗睘鎬у拰鏂規(guī)硶鐨勬敮鎸侊紝寰堝鏄撳氨鑳界紪鍐欏嚭涓涓ā鎷熸祻瑙堝櫒鑷姩鐧誨綍鐨勭▼搴忋偮?br /><br />紼嬪簭浣跨敤聽HTTP聽鍗忚鍜屾湇鍔″櫒浜や簰涓昏鏄繘琛屾暟鎹殑鎻愪氦錛岄氬父鏁版嵁鐨勬彁浜ゆ槸閫氳繃聽GET聽鍜屄燩OST聽涓ょ鏂瑰紡鏉ュ畬鎴愶紝涓嬮潰瀵硅繖涓ょ鏂瑰紡榪涜涓涓嬭鏄庯細聽<br /><br />1.聽GET聽 鏂瑰紡銆偮燝ET聽鏂瑰紡閫氳繃鍦ㄧ綉緇滃湴鍧闄勫姞鍙傛暟鏉ュ畬鎴愭暟鎹殑鎻愪氦錛屾瘮濡傚湪鍦板潃聽http://www.google.com/webhp?hl=zh- CN聽涓紝鍓嶉潰閮ㄥ垎聽http://www.google.com/webhp聽琛ㄧず鏁版嵁鎻愪氦鐨勭綉鍧錛屽悗闈㈤儴鍒喡爃l=zh-CN聽琛ㄧず闄勫姞鐨勫弬鏁幫紝鍏朵腑 聽hl聽琛ㄧず涓涓敭(key)錛屄爖h-CN聽琛ㄧず榪欎釜閿搴旂殑鍊?value)銆傜▼搴忎唬鐮佸涓嬶細聽<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">HttpWebRequest聽req聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(HttpWebRequest)聽HttpWebRequest.Create(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.google.com/webhp?hl=zh-CN</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽);<br />req.Method聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">GET</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽(WebResponse聽wr聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽req.GetResponse())<br />{<br />聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍦ㄨ繖閲屽鎺ユ敹鍒扮殑欏甸潰鍐呭榪涜澶勭悊</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">}聽<br /></span></div><br />2.聽POST聽鏂瑰紡銆偮燩OST聽鏂瑰紡閫氳繃鍦ㄩ〉闈㈠唴瀹逛腑濉啓鍙傛暟鐨勬柟娉曟潵瀹屾垚鏁版嵁鐨勬彁浜わ紝鍙傛暟鐨勬牸寮忓拰聽GET聽鏂瑰紡涓鏍鳳紝鏄被浼間簬聽hl=zh-CN&newwindow=1聽榪欐牱鐨勭粨鏋勩傜▼搴忎唬鐮佸涓嬶細聽<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽param聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">hl=zh-CN&newwindow=1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[]聽bs聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Encoding.ASCII.GetBytes(param);<br /><br />HttpWebRequest聽req聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(HttpWebRequest)聽HttpWebRequest.Create(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.google.com/intl/zh-CN/</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽);<br />req.Method聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">POST</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />req.ContentType聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">application/x-www-form-urlencoded</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />req.ContentLength聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽bs.Length;<br /><br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽(Stream聽reqStream聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽req.GetRequestStream())<br />{<br />聽聽聽reqStream.Write(bs,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">,聽bs.Length);<br />}<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽(WebResponse聽wr聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽req.GetResponse())<br />{<br />聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍦ㄨ繖閲屽鎺ユ敹鍒扮殑欏甸潰鍐呭榪涜澶勭悊</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">}聽</span></div><br /><br />鍦ㄤ笂闈㈢殑浠g爜涓紝鎴戜滑璁塊棶浜喡爓ww.google.com聽鐨勭綉鍧錛屽垎鍒互聽GET聽鍜屄燩OST聽鏂瑰紡鎻愪氦浜嗘暟鎹紝騫舵帴鏀朵簡榪斿洖鐨勯〉闈㈠唴瀹廣傜劧鑰岋紝濡傛灉鎻愪氦鐨勫弬鏁頒腑鍚湁涓枃錛岄偅涔堣繖鏍風殑澶勭悊鏄笉澶熺殑錛岄渶瑕佸鍏惰繘琛岀紪鐮侊紝璁╁鏂圭綉绔欒兘澶熻瘑鍒偮?br /><br />3.聽浣跨敤聽GET聽鏂瑰紡鎻愪氦涓枃鏁版嵁銆偮燝ET聽鏂瑰紡閫氳繃鍦ㄧ綉緇滃湴鍧涓檮鍔犲弬鏁版潵瀹屾垚鏁版嵁鎻愪氦錛屽浜庝腑鏂囩殑緙栫爜錛屽父鐢ㄧ殑鏈壜爂b2312聽鍜屄爑tf8聽涓ょ錛岀敤聽gb2312聽鏂瑰紡緙栫爜璁塊棶鐨勭▼搴忎唬鐮佸涓嬶細聽<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Encoding聽myEncoding聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Encoding.GetEncoding(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">gb2312</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽address聽聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.baidu.com/s?</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽HttpUtility.UrlEncode(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍙傛暟涓</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽myEncoding)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽HttpUtility.UrlEncode(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍊間竴</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽myEncoding);<br />HttpWebRequest聽req聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(HttpWebRequest)HttpWebRequest.Create(address);<br />req.Method聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">GET</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽(WebResponse聽wr聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽req.GetResponse())<br />{<br />聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍦ㄨ繖閲屽鎺ユ敹鍒扮殑欏甸潰鍐呭榪涜澶勭悊</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">}聽</span></div><br /><br />鍦? 涓婇潰鐨勭▼搴忎唬鐮佷腑錛屾垜浠互聽GET聽鏂瑰紡璁塊棶浜嗙綉鍧聽http://www.baidu.com/s聽錛屼紶閫掍簡鍙傛暟鈥滃弬鏁頒竴=鍊間竴鈥濓紝鐢變簬鏃犳硶鍛婄煡瀵規(guī)柟鎻? 浜ゆ暟鎹殑緙栫爜綾誨瀷錛屾墍浠ョ紪鐮佹柟寮忚浠ュ鏂圭殑緗戠珯涓烘爣鍑嗐傚父瑙佺殑緗戠珯涓紝聽www.baidu.com聽錛堢櫨搴︼級鐨勭紪鐮佹柟寮忔槸聽gb2312, 聽www.google.com聽錛堣胺姝岋級鐨勭紪鐮佹柟寮忔槸聽utf8銆偮?br /><br />4.聽浣跨敤聽POST聽鏂瑰紡鎻愪氦涓枃鏁版嵁銆偮燩OST聽鏂瑰紡閫氳繃鍦ㄩ〉闈㈠唴瀹逛腑濉啓鍙傛暟鐨勬柟娉曟潵瀹屾垚鏁版嵁鐨勬彁浜わ紝鐢變簬鎻愪氦鐨勫弬鏁頒腑鍙互璇存槑浣跨敤鐨勭紪鐮佹柟寮忥紝鎵浠ョ悊璁轟笂鑳借幏寰楁洿澶х殑鍏煎鎬с傜敤聽gb2312聽鏂瑰紡緙栫爜璁塊棶鐨勭▼搴忎唬鐮佸涓嬶細聽<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 0);">Encoding聽myEncoding聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Encoding.GetEncoding(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">gb2312</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽param聽聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽HttpUtility.UrlEncode(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍙傛暟涓</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽myEncoding)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽HttpUtility.UrlEncode聽(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍊間竴</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽myEncoding)聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">&</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽HttpUtility.UrlEncode(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍙傛暟浜?/span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽myEncoding)聽聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽HttpUtility.UrlEncode(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍊間簩</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽myEncoding);<br /><br /></span><span style="color: rgb(0, 0, 255);">byte</span><span style="color: rgb(0, 0, 0);">[]聽postBytes聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Encoding.ASCII.GetBytes(param);<br /><br />HttpWebRequest聽req聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽(HttpWebRequest)聽HttpWebRequest.Create(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.baidu.com/s</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽);<br />req.Method聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">POST</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />req.ContentType聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">application/x-www-form-urlencoded;charset=gb2312</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />req.ContentLength聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽postBytes.Length;<br /><br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽(Stream聽reqStream聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽req.GetRequestStream())<br />{<br />聽聽聽reqStream.Write(</span><span style="color: rgb(0, 0, 0);">postBytes </span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">, </span><span style="color: rgb(0, 0, 0);">postBytes </span><span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 0);">.Length);<br />}<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽(WebResponse聽wr聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽req.GetResponse())<br />{<br />聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍦ㄨ繖閲屽鎺ユ敹鍒扮殑欏甸潰鍐呭榪涜澶勭悊</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">}聽</span></div><br /><br />浠庝笂闈㈢殑浠g爜鍙互鐪嬪嚭錛屄燩OST聽涓枃鏁版嵁鐨勬椂鍊欙紝鍏堜嬌鐢燯rlEncode聽鏂規(guī)硶灝嗕腑鏂囧瓧絎﹁漿鎹負緙栫爜鍚庣殑聽ASCII聽鐮侊紝鐒跺悗鎻愪氦鍒版湇鍔″櫒錛屾彁浜ょ殑鏃跺欏彲浠ヨ鏄庣紪鐮佺殑鏂瑰紡錛岀敤鏉ヤ嬌瀵規(guī)柟鏈嶅姟鍣ㄨ兘澶熸紜殑瑙f瀽銆偮?br /><br />浠? 涓婂垪鍑轟簡瀹㈡埛绔▼搴忎嬌鐢燞TTP聽鍗忚涓庢湇鍔″櫒浜や簰鐨勬儏鍐碉紝甯哥敤鐨勬槸聽GET聽鍜屄燩OST聽鏂瑰紡銆傜幇鍦ㄦ祦琛岀殑聽WebService聽涔熸槸閫氳繃 聽HTTP聽鍗忚鏉ヤ氦浜掔殑錛屼嬌鐢ㄧ殑鏄燩OST聽鏂規(guī)硶銆備笌浠ヤ笂紼嶆湁鎵涓嶅悓鐨勬槸錛屄燱ebService聽鎻愪氦鐨勬暟鎹唴瀹瑰拰鎺ユ敹鍒扮殑鏁版嵁鍐呭閮芥槸浣跨敤浜? 聽XML聽鏂瑰紡緙栫爜銆傛墍浠ワ紝聽HttpWebRequest聽涔熷彲浠ヤ嬌鐢ㄥ湪璋冪敤聽WebService聽鐨勬儏鍐典笅銆?img src ="http://www.tkk7.com/killme2008/aggbug/105023.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/killme2008/" target="_blank">dennis</a> 2007-03-20 16:32 <a href="http://www.tkk7.com/killme2008/archive/2007/03/20/105023.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍒涘緩鍨嬫ā寮忔憳璁?/title><link>http://www.tkk7.com/killme2008/archive/2007/03/17/104485.html</link><dc:creator>dennis</dc:creator><author>dennis</author><pubDate>Sat, 17 Mar 2007 09:01:00 GMT</pubDate><guid>http://www.tkk7.com/killme2008/archive/2007/03/17/104485.html</guid><wfw:comment>http://www.tkk7.com/killme2008/comments/104485.html</wfw:comment><comments>http://www.tkk7.com/killme2008/archive/2007/03/17/104485.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.tkk7.com/killme2008/comments/commentRss/104485.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/killme2008/services/trackbacks/104485.html</trackback:ping><description><![CDATA[聽聽聽 緋葷粺鐨勬紨鍖栧簲褰撲緷璧栦簬緇勫悎錛岃屼笉鏄戶鎵匡紱榪欏氨鎻愬嚭浜嗗皢綾葷殑瀹炰緥鍖栧鎵樼粰涓涓璞$殑瑕佹眰錛屽洜姝ゅ垱寤哄瀷妯″紡灝嗗彉鐨勮秺鏉ヨ秺閲嶈銆?br /><div style="text-indent: 21pt;">鍒涘緩鍨嬫ā寮忓睘浜庡璞″垱寤烘ā鍨嬨傛墍璋撳璞″垱寤烘ā鍨嬪氨鏄灝嗗疄渚嬪寲鐨勫伐浣滃鎵樼粰鍙︿竴涓璞℃潵鍋氥備笌涔嬬浉瀵瑰簲鐨勬槸綾誨垱寤烘ā鍨嬶紝榪欐槸涓縐嶉氳繃緇ф壙鏀瑰彉琚疄渚嬪寲鐨勭被銆?/div><div><span>聽聽聽聽聽聽 </span>鍒涘緩鍨嬫ā寮忔湁涓や釜閲嶈鐨勭壒鐐癸細</div><div style="margin-left: 39pt; text-indent: -18pt;"><span>1錛壜?/span>瀹㈡埛涓嶇煡閬撳垱寤虹殑鍏蜂綋綾繪槸浠涔堬紙闄ら潪鐪嬫簮浠g爜錛?/div><div style="margin-left: 39pt; text-indent: -18pt;"><span>2錛壜?/span>闅愯棌浜嗙被鐨勫疄渚嬫槸濡備綍琚垱寤哄拰鏀懼湪涓璧風殑</div><br />涓銆傛娊璞″伐鍘傛ā寮?br />1.鎰忓浘錛氭彁渚涗竴涓垱寤?b>涓緋誨垪</b>鐩稿叧鎴栫浉浜掍緷璧栧璞$殑鎺ュ彛錛岃屾棤闇鎸囧畾瀹冧滑鐨勫叿浣撶殑綾匯?br />2.閫傜敤鍦烘櫙錛?br />1)涓涓郴緇熻鐙珛浜庡畠鐨勪駭鍝佺殑鍒涘緩銆佺粍鍚堝拰琛ㄧず鏃?br />2錛変竴涓郴緇熻鐢卞涓駭鍝佺郴鍒椾腑鐨勪竴涓潵閰嶇疆鏃?br />3錛夊綋浣犺寮鴻皟涓緋誨垪鐩稿叧鐨勪駭鍝佸璞$殑璁捐浠ヤ究榪涜鑱斿悎浣跨敤鏃?br />4錛夊綋浣犳彁渚涗竴涓駭鍝佺被搴擄紝鑰屽彧鎯蟲樉紺哄畠浠殑鎺ュ彛鑰屼笉鏄疄鐜版椂<br /><br />3.UML鍥鋸斺旂粨鏋?br /><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/sheismylife/07cbd5dfdbdd4027a1ed513e503b1d6f.png" /><br />4.鏁堟灉錛?br />1錛夊垎紱諱簡鍏蜂綋鐨勭被錛岄氳繃鎶借薄鎺ュ彛灝嗗鎴蜂笌鍏蜂綋鐨勭被鍒嗙<br />2錛夋槗浜庝氦鎹駭鍝佺郴鍒?br />3錛夋湁鍒╀簬浜у搧鐨勪竴鑷存?br />4錛夐毦浠ユ敮鎸佹柊縐嶇被鐨勪駭鍝侊紝姣斿鎴戜滑鐜板湪鏈変竴涓狿roductC浜у搧錛屾垜浠渶瑕佸鍔犵被AbstractProductC錛屽鍔燗bstractFactory:: CreanteProductC鏂規(guī)硶錛屽茍涓斾袱涓駭鍝佺郴鍒楃殑瀹為檯鍒涘緩鑰匔onCreateFactory1銆丆onCreateFactor2閮借瀹炵幇璇ユ柟 娉曘?div>鍙互閫氳繃緇欐柟娉曞姞鍙傛暟鐨勬柟寮忔潵鎸囨槑鍒涘緩鐨勬槸浠涔堜駭鍝侊紝榪欐牱瀹㈡埛浠g爜灝辨棤闇鏀瑰彉錛屽彧瑕佷紶閫掍笉鍚岀殑鍙傛暟銆侫bstractFactory綾誨彧闇瑕佹彁渚涗竴涓狢reateProduct(const string& name)鏂規(guī)硶鍗沖彲銆?br /><br />5.浠g爜瀹炵幇錛屼互銆婃繁鍏ユ祬鍑鴻璁℃ā寮?java C#)銆嬬殑鍔ㄧ墿宸ュ巶涓轟緥錛?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System;<br /></span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">聽AnimalWorld<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽鎶借薄澶ч檰宸ュ巶</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽ContinentFactory<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Herbivore聽CreateHerbivore();<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Carnivore聽CreateCarnivore();<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">闈炴床澶ч檰,鏈夎椹紝鐙瓙</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽AfricaFactory聽:聽ContinentFactory<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Herbivore聽CreateHerbivore()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Wildebeest();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Carnivore聽CreateCarnivore()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Lion();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽緹庢床澶ч檰,鏈夌嫾,閲庣墰</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽AmericaFactory聽:聽ContinentFactory<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Herbivore聽CreateHerbivore()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Bison();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Carnivore聽CreateCarnivore()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Wolf();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">椋熻崏鍔ㄧ墿"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Herbivore<br />聽聽聽聽{<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鑲夐鍔ㄧ墿"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Carnivore<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鐚庨椋熻崏鍔ㄧ墿鐨勬柟娉?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Eat(聽Herbivore聽h聽);<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">瑙掗┈</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Wildebeest聽:聽Herbivore<br />聽聽聽聽{<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鐙瓙"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Lion聽:聽Carnivore<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">閲嶈澆鐚庨椋熻崏鍔ㄧ墿鐨勬柟娉?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Eat(聽Herbivore聽h聽)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽eats聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽h聽);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">閲庣墰</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Bison聽:聽Herbivore<br />聽聽聽聽{<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鐙?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Wolf聽:聽Carnivore<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">閲嶈澆鐚庨椋熻崏鍔ㄧ墿鐨勬柟娉?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Eat(聽Herbivore聽h聽)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽eats聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽h聽);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍔ㄧ墿涓栫晫綾?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽AnimalWorld<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽Herbivore聽herbivore;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽Carnivore聽carnivore;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽鍒涘緩涓ょ鍔ㄧ墿鍒嗙被</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽AnimalWorld(聽ContinentFactory聽factory聽)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽carnivore聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽factory.CreateCarnivore();<br />聽聽聽聽聽聽聽聽聽聽聽聽herbivore聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽factory.CreateHerbivore();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">榪愯椋熺墿閾?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽RunFoodChain()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鑲夐鍔ㄧ墿鐚庨椋熻崏鍔ㄧ墿</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽carnivore.Eat(聽herbivore聽);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">聽</span><span style="color: rgb(128, 128, 128);"><summary></span><span style="color: rgb(0, 128, 0);"><br />聽聽聽聽</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">聽鎶借薄宸ュ巶妯″紡瀹㈡埛搴旂敤嫻嬭瘯<br />聽聽聽聽</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">聽</span><span style="color: rgb(128, 128, 128);"></summary></span><span style="color: rgb(128, 128, 128);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽GameApp<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽[STAThread]<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Main(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">[]聽args)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍒涢犲茍榪愯闈炴床鍔ㄧ墿涓栫晫</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽ContinentFactory聽africa聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽AfricaFactory();<br />聽聽聽聽聽聽聽聽聽聽聽聽AnimalWorld聽world聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽AnimalWorld(聽africa聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽world.RunFoodChain();<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍒涢犲茍榪愯緹庢床鍔ㄧ墿涓栫晫</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽ContinentFactory聽america聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽AmericaFactory();<br />聽聽聽聽聽聽聽聽聽聽聽聽world聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽AnimalWorld(聽america聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽world.RunFoodChain();<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.Read();<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽}<br />}<br /></span></div><br />浜屻侭uilder妯″紡<br />1.鎰忓浘錛氬皢涓涓?b>澶嶆潅瀵硅薄</b>鐨勬瀯寤轟笌瀹冪殑琛ㄧず鐩稿垎紱伙紝浣垮緱鍚屾牱鐨勬瀯寤鴻繃紼嬪彲浠ュ垱寤轟笉鍚岀殑琛ㄧず錛堟垨鑰呰浜у搧錛?br /><br />2.閫傜敤鍦烘櫙錛?br />1錛夊綋鍒涘緩澶嶆潅瀵硅薄鐨勭畻娉曞簲璇ョ嫭绔嬩簬鏀瑰璞$殑緇勬垚閮ㄥ垎浠ュ強瀹冧滑鐨勮閰嶆柟寮忔椂<br />2錛夊綋鏋勯犺繃紼嬪繀欏誨厑璁歌鏋勯犵殑瀵硅薄鏈変笉鍚岀殑琛ㄧず鏃?br /><br />3.UML鍥鋸斺旂粨鏋?br /><br /><img src="file:///C:/DOCUME%7E1/Admin/LOCALS%7E1/Temp/moz-screenshot-2.jpg" alt="" /><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/sheismylife/c9bff79b4fbd48859316f43e1b61a265.png" /><br /><img src="file:///C:/DOCUME%7E1/Admin/LOCALS%7E1/Temp/moz-screenshot.jpg" alt="" /><img src="file:///C:/DOCUME%7E1/Admin/LOCALS%7E1/Temp/moz-screenshot-1.jpg" alt="" />Director鎺ュ彈涓涓狟uilder瀛愮被瀵硅薄錛屽畬鎴愬垱寤鴻繃紼嬶紝騫墮氱煡Builder瀵硅薄榪斿洖浠ュ強鏋勯犲ソ鐨勪駭鍝併?br /><br />4.鏁堟灉錛?br />1錛夊彲浠ヤ嬌浣犳敼鍙樹竴涓璞$殑鍐呴儴琛ㄧず<br />2錛夋瀯閫犱唬鐮佸拰琛ㄧず浠g爜鍒嗗紑<br />3錛夊彲浠ュ鏋勯犺繃紼嬭繘琛屾洿綺劇粏鐨勬帶鍒?br /><br />5銆傚疄鐜幫細浠ヤ竴涓濺杈嗗緩閫犺繃紼嬩負渚嬶紙C#)<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System;<br /><br /></span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">聽CarShop<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System.Collections;<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鎸囨尌鑰?Director</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Shop{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Construct(聽VehicleBuilder聽vehicleBuilder聽){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicleBuilder.BuildFrame();<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicleBuilder.BuildEngine();<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicleBuilder.BuildWheels();<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicleBuilder.BuildDoors();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">/*</span><span style="color: rgb(0, 128, 0);">聽"Builder聽寤洪犺?,Builder<br />聽聽聽聽鎶借薄寤洪犺呭叿鏈夊洓縐嶆柟娉?br />聽聽聽聽瑁呴厤妗嗘灦<br />聽聽聽聽瑁呴厤鍙戝姩鏈?br />聽聽聽聽瑁呴厤杞瓙<br />聽聽聽聽瑁呴厤杞﹂棬<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">*/</span><span style="color: rgb(0, 0, 0);"><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽VehicleBuilder<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">protected</span><span style="color: rgb(0, 0, 0);">聽Vehicle聽vehicle;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">榪斿洖寤洪犲畬鎴愮殑杞﹁締</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Vehicle聽Vehicle{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽vehicle;聽}<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildFrame();<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildEngine();<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildWheels();<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildDoors();<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍏蜂綋寤洪犺?鎽╂墭杞﹁濺闂?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽MotorCycleBuilder聽:聽VehicleBuilder<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildFrame(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Vehicle(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鎽╂墭杞?/span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">MotorCycle聽Frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildEngine(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">engine</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">500聽cc</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildWheels(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">wheels</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildDoors(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">doors</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鍏蜂綋寤洪犺?杞胯濺杞﹂棿</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽CarBuilder聽:聽VehicleBuilder<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildFrame(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Vehicle(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">杞胯濺</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Car聽Frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildEngine(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">engine</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">2500聽cc</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildWheels(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">wheels</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildDoors(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">doors</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">4</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽鍏蜂綋寤洪犺?鍗曡剼婊戣杞﹁濺闂?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽ScooterBuilder聽:聽VehicleBuilder<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildFrame(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Vehicle(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">鍗曡剼婊戣杞?/span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Scooter聽Frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildEngine(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">engine</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">none</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildWheels(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">wheels</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽BuildDoors(){<br />聽聽聽聽聽聽聽聽聽聽聽聽vehicle[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">doors</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">杞﹁締浜у搧綾?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Vehicle<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽type;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽Hashtable聽parts聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Hashtable();<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">絳戞瀯鍑芥暟,鍐沖畾綾誨瀷</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Vehicle(聽</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽type聽){<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.type聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽type;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">绱㈠紩</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">[聽</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽key聽]{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">{聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽parts[聽key聽];聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">set</span><span style="color: rgb(0, 0, 0);">{聽parts[聽key聽]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽value;聽}<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鏄劇ず鏂規(guī)硶</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Show()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">\n---------------------------</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">杞﹁締綾葷被鍨?聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽type聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽妗嗘灦聽:聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽parts[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">frame</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽鍙戝姩鏈郝?聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽parts[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">engine</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽#杞瓙鏁?聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽parts[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">wheels</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽#杞﹂棬鏁奧?聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽parts[聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">doors</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽]聽);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">聽</span><span style="color: rgb(128, 128, 128);"><summary></span><span style="color: rgb(0, 128, 0);"><br />聽聽聽聽</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">聽寤洪犺呮ā寮忓簲鐢ㄦ祴璇?br />聽聽聽聽</span><span style="color: rgb(128, 128, 128);">///</span><span style="color: rgb(0, 128, 0);">聽</span><span style="color: rgb(128, 128, 128);"></summary></span><span style="color: rgb(128, 128, 128);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽CarShop<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽[STAThread]<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Main(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">[]聽args)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽鍒涢犺濺闂村強杞﹁締寤洪犺?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽Shop聽shop聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Shop();<br />聽聽聽聽聽聽聽聽聽聽聽聽VehicleBuilder聽b1聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽ScooterBuilder();<br />聽聽聽聽聽聽聽聽聽聽聽聽VehicleBuilder聽b2聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽CarBuilder();<br />聽聽聽聽聽聽聽聽聽聽聽聽VehicleBuilder聽b3聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽MotorCycleBuilder();<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽絳戞瀯騫舵樉紺鴻濺杈?/span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽聽聽聽聽shop.Construct(聽b1聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽b1.Vehicle.Show();<br />聽聽聽聽聽聽聽聽聽聽聽聽shop.Construct(聽b2聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽b2.Vehicle.Show();<br />聽聽聽聽聽聽聽聽聽聽聽聽shop.Construct(聽b3聽);<br />聽聽聽聽聽聽聽聽聽聽聽聽b3.Vehicle.Show();<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.Read();<br /><br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />}<br /></span></div><br /><br /><strong></strong>涓夈侳actory Method妯″紡<br />1.鎰忓浘錛氬畾涔変竴涓敤浜庡垱寤哄璞$殑鎺ュ彛錛岃瀛愮被鍐沖畾瀹炰緥鍖栧叿浣撶殑鍝竴涓被銆?br />2.閫傜敤鍦烘櫙錛?br />1錛夊綋涓涓被涓嶇煡閬撳畠鎵蹇呴』鍒涘緩鐨勫璞$殑綾葷殑鏃跺欙紝璁╁瓙綾繪潵鍐沖畾<br />2錛夊綋涓涓被甯屾湜鐢卞畠鐨勫瓙綾繪潵鍐沖畾瀹冩墍鍒涘緩鐨勫璞$殑鏃跺?br /><br />3銆俇ML鍥鋸斺旂粨鏋勶細<br /><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/sheismylife/638ccee7f75e4632a78bdda0a084690b.png" /><br />4.鏁堟灉錛?br />1錛変負瀛愮被鎻愪緵鍥炶皟鍑芥暟<br />2錛夎繛鎺ュ鉤琛岀殑綾誨眰嬈?br /><div style="margin-left: 18pt; text-indent: -18pt;"><span>3錛壜?/span>鍒涘緩鍑芥暟鍙互鎺ユ敹鍙傛暟鏉ュ喅瀹氬垱寤轟粈涔堜駭鍝?/div><div>4錛塅actory Method瀹規(guī)槗瀵艱嚧鍒涘緩榪囧鐨凜reator鐨勫瓙綾諱互瀵瑰簲涓嶅悓鐨勪駭鍝侊紝榪欎釜鏂規(guī)硶鍙互閫氳繃妯℃澘鎶鏈潵瑙e喅<br /><br />6.瀹炵幇錛屾墜鏈哄伐鍘傦紝浜у搧鍙兘鏄疦okia錛屼篃鍙兘鏄疢otorola<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System;<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System.Collections.Generic;<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System.Text;<br /><br /></span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">聽HandPhone<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鎵嬫満鎺ュ彛</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">interface</span><span style="color: rgb(0, 0, 0);">聽Mobile<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽call();<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">鎵嬫満宸ュ巶鎺ュ彛</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">interface</span><span style="color: rgb(0, 0, 0);">聽MobileFactory<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽Mobile聽createMobile();<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">Nokia</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Nokia:Mobile<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽call()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">This聽is聽a聽{0}聽phone</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.GetType().Name);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">Motorola</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Motorola聽:聽Mobile<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽call()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">This聽is聽a聽{0}聽phone</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.GetType().Name);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">Motorola宸ュ巶</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽MotorolaFactory聽:聽MobileFactory<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Mobile聽createMobile()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Motorola();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">Nokia宸ュ巶</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽NokiaFactroy聽:聽MobileFactory<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Mobile聽createMobile()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Nokia();<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Client<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Main(String聽[]args)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽MobileFactory聽factory</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽聽聽聽聽Mobile聽mobile</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">;<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽factory</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽NokiaFactroy();<br />聽聽聽聽聽聽聽聽聽聽聽聽mobile</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">factory.createMobile();<br />聽聽聽聽聽聽聽聽聽聽聽聽mobile.call();<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽factory</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽MotorolaFactory();<br />聽聽聽聽聽聽聽聽聽聽聽聽mobile</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">factory.createMobile();<br />聽聽聽聽聽聽聽聽聽聽聽聽mobile.call();<br />聽聽聽聽聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />}<br /></span></div><br />鍥涖侾rototype妯″紡<br /><br />1.鎰忓浘錛氶氳繃鍘熷瀷瀹炰緥鎸囧畾鍒涘緩瀵硅薄鐨勭綾伙紝騫墮氳繃鎷瘋礉榪欎簺鍘熷瀷鏉ュ垱寤烘柊鐨勫璞?br /><br />2.閫傜敤鍦烘櫙錛?br />1錛夎瀹炰緥鍖栫殑綾繪槸鍦ㄨ繍琛屾椂鍒繪寚瀹氱殑錛屾瘮濡傚姩鎬佽杞?br />2錛変負浜嗛伩鍏嶅垱寤轟竴涓笌浜у搧灞傛騫寵鐨勫伐鍘傜被灞傛<br />3錛夊綋涓涓被鐨勫疄渚嬪彧鑳芥湁鍑犱釜涓嶅悓鐨勭姸鎬佺粍鍚堜腑鐨勪竴縐嶆椂錛屽緩绔嬬浉搴旀暟鐩殑鍘熷瀷騫跺厠闅嗗畠浠彲鑳芥瘮姣忔鐢ㄥ悎閫傜殑鐘舵佹墜宸ュ寲璇ョ被鏇存柟渚夸竴浜涖?br /><br />3.UML鍥鋸斺旂粨鏋勶細<br /><img src="http://p.blog.csdn.net/images/p_blog_csdn_net/sheismylife/9767a24f6e804101a9c0ae875105f950.png" /><br /><br /></div><br />4.鏁堟灉錛?br />1錛夎繍琛屾椂鍔ㄦ佸鍔犳垨鑰呭垹闄や駭鍝?br />2錛夊噺灝戝瓙綾葷殑鏋勯犳暟鐩?br />3錛夌敤綾誨姩鎬侀厤緗簲鐢?br />4錛夊姩鎬佹寚瀹氭柊鐨勫璞★紝閫氳繃鏀瑰彉緇撴瀯鎴栬呭?br />5錛夌己闄峰湪浜庢瘡涓涓狿rototype鐨勫瓙綾婚兘闇瑕佸疄鐜癱lone鎿嶄綔<br /><br />5銆傚疄鐜?鏃犺java榪樻槸C#閮戒粠璇█灞傛鍐呯疆浜嗗prototype妯″紡鐨勬敮鎸併傚叿浣撲笉鍐嶈榪般?br /><br />浜斻俿ingleton妯″紡<br />1銆傛剰鍥撅細淇濊瘉涓涓被浠呮湁涓涓疄渚嬶紝騫舵彁渚涗竴涓闂畠鐨勫叏灞璁塊棶鐐?br /><br />2.閫傜敤鍦烘櫙錛?br />1錛夊綋闇瑕佺被鍙湁涓涓疄渚嬶紝騫朵笖瀹㈡埛鍙兘閫氳繃涓涓叏灞鐐瑰幓璁塊棶瀹?br />2錛夊綋榪欎釜鍞竴瀹炰緥搴旇鏄氳繃瀛愮被鍖栧彲鎵╁睍鐨勶紝騫朵笖瀹㈡埛搴旇鏃犻渶鏇存敼浠g爜灝辮兘浣跨敤鎵╁睍鐨勫疄渚?br /><br />3.UML鍥撅細鐣?br /><br />4.鏁堟灉錛?br />1錛夊鍞竴瀹炰緥鐨勫彈鎺ц闂?br />2錛夌緝?yōu)畯鍛藉悕绌洪?br />3錛夊厑璁稿鎿嶄綔鍜岃〃紺虹殑緇嗗寲<br />4錛夊厑璁稿彲鍙樻暟鐩殑瀹炰緥<br /><br />5瀹炵幇錛屽叧浜巗ingleton鍦╦ava澶氱嚎紼嬬幆澧冧笅鐨勫疄鐜幫紝璇瘋璁ㄨ銆?a id="viewpost1_TitleUrl" class="postTitle2" >褰揝ingleton閬囧埌multi-threading</a>銆嬶紝C#瀵箂ingleton澶氱嚎紼嬬幆澧冧笅鐨勮兘澶熸紜疄鐜癉ouble-checked妯″紡錛?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">sealed</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Singleton<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">volatile</span><span style="color: rgb(0, 0, 0);">聽Singleton聽instance;<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">聽syncRoot聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Object();<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);">聽Singleton()聽{}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽Singleton聽Instance<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">get</span><span style="color: rgb(0, 0, 0);">聽<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(instance聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)聽<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">lock</span><span style="color: rgb(0, 0, 0);">聽(syncRoot)聽<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(instance聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)聽<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽instance聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Singleton();<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽instance;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />}</span></div><br /><br />鏈枃浠呬綔閫熸煡璁板繂鐢紝鎽樿浜庛婅璁℃ā寮忊斺斿彲澶嶇敤闈㈠悜瀵硅薄杞歡鍩虹銆嬪拰銆婃繁鍏ユ祬鍑鴻璁℃ā寮忥紙java C#)銆嬩袱涔?br /><br /></div><img src ="http://www.tkk7.com/killme2008/aggbug/104485.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/killme2008/" target="_blank">dennis</a> 2007-03-17 17:01 <a href="http://www.tkk7.com/killme2008/archive/2007/03/17/104485.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍥炬枃騫惰寕鈥斺斾嬌鐢▁fire緙栧啓webservice,騫墮氳繃C#璋冪敤http://www.tkk7.com/killme2008/archive/2007/03/07/102450.htmldennisdennisWed, 07 Mar 2007 10:13:00 GMThttp://www.tkk7.com/killme2008/archive/2007/03/07/102450.htmlhttp://www.tkk7.com/killme2008/comments/102450.htmlhttp://www.tkk7.com/killme2008/archive/2007/03/07/102450.html#Feedback9http://www.tkk7.com/killme2008/comments/commentRss/102450.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/102450.html闃呰鍏ㄦ枃

dennis 2007-03-07 18:13 鍙戣〃璇勮
]]>
C#鐨剈sing璇彞http://www.tkk7.com/killme2008/archive/2007/02/12/99470.htmldennisdennisMon, 12 Feb 2007 07:53:00 GMThttp://www.tkk7.com/killme2008/archive/2007/02/12/99470.htmlhttp://www.tkk7.com/killme2008/comments/99470.htmlhttp://www.tkk7.com/killme2008/archive/2007/02/12/99470.html#Feedback0http://www.tkk7.com/killme2008/comments/commentRss/99470.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/99470.htmlC#鐨剈sing璇彞璁捐鐨勮洰璐村績錛屾瘮java鐨刬mport鏈夎叮涓鐐廣傝漿涓綃囨枃绔?

C#涓殑using闄や簡浣滀負鍛藉悕絀洪棿鎸囩ず絎?using System)錛岀被鍨嬬殑鍒悕鎸囩ず絎?using Dos=System.Console)錛岃繕鏈夎祫婧愮鐞嗙殑璇彞鍔熻兘錛?br /> using (R r1 = new R ()) {
聽 聽r1.F();
}
鍦–#涓緲昏瘧涓猴細
R聽r1聽=new聽R();
try聽{
聽聽聽r1.F();
}
finally聽{
聽聽聽
if聽(r1聽!=null)聽((IDisposable)r1).Dispose();
}

r1褰撶劧瑕佹敮鎸丏ispose()鏂規(guī)硶浜?br />
鍐嶆潵涓涓緥瀛愶細
#聽MyObject.cs

using 聽System;



namespace 聽MyProjects

{

聽聽聽聽
public class 聽MyObject聽:聽IDisposable

聽聽聽聽{

聽聽聽聽聽聽聽聽
public 聽MyObject()

聽聽聽聽聽聽聽聽{

聽聽聽聽聽聽聽聽}



聽聽聽聽聽聽聽聽
public void 聽Dispose聽(聽)

聽聽聽聽聽聽聽聽{

聽聽聽聽聽聽聽聽聽聽聽聽
// 聽Dispose

聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine聽(聽
" Disposed " 聽)聽;

聽聽聽聽聽聽聽聽聽聽聽聽
//

聽聽聽聽聽聽聽聽}

聽聽聽聽}

}



#聽Class1.cs

using 聽System;



namespace 聽MyProjects

{

聽聽聽聽聽
public class 聽Class1

聽聽聽聽聽{

聽聽聽聽聽聽聽聽聽
public 聽Class1()

聽聽聽聽聽聽聽聽聽{

聽聽聽聽聽聽聽聽聽}



聽聽聽聽聽聽聽聽聽
public static void 聽Main聽(聽 string []聽args聽)

聽聽聽聽聽聽聽聽聽{

聽聽聽聽聽聽聽聽聽聽聽聽聽聽
using 聽(聽MyObject聽myObject聽 = new 聽MyObject聽(聽)聽)

聽聽聽聽聽聽聽聽聽聽聽聽聽聽{

聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine聽(聽
" quit " 聽)聽;

聽聽聽聽聽聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽聽聽聽聽}

聽聽聽聽聽}

}



浣跨敤using浼氳嚜鍔ㄨ皟鐢?span lang="EN-US">MyObject鐨?span lang="EN-US">Dispose鏂規(guī)硶.


dennis 2007-02-12 15:53 鍙戣〃璇勮
]]>
C#鐨勭被鍨嬬郴緇?/title><link>http://www.tkk7.com/killme2008/archive/2007/02/12/99418.html</link><dc:creator>dennis</dc:creator><author>dennis</author><pubDate>Mon, 12 Feb 2007 04:30:00 GMT</pubDate><guid>http://www.tkk7.com/killme2008/archive/2007/02/12/99418.html</guid><wfw:comment>http://www.tkk7.com/killme2008/comments/99418.html</wfw:comment><comments>http://www.tkk7.com/killme2008/archive/2007/02/12/99418.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/killme2008/comments/commentRss/99418.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/killme2008/services/trackbacks/99418.html</trackback:ping><description><![CDATA[涓.C#鐨勭粺涓綾誨瀷緋葷粺<br />1.C#鐨勭被鍨嬬郴緇熸槸緇熶竴鐨勶紝java鐨勭被鍨嬬郴緇熷垎涓猴細鍩烘湰綾誨瀷錛堝師鐢熺被鍨嬶級鍜岀被綾誨瀷錛岃孋#鐨勬墍鏈夌被鍨嬬洿鎺ユ垨闂存帴鍦頒粠object綾葷被鍨嬫淳鐢熻屾潵錛屼粠綾誨瀷緋葷粺涓婃潵鐪嬫瘮java鏇碠O銆?br />2.C#鐨勭被鍨嬪垎涓轟笁綾伙細<br />錛?錛夊肩被鍨嬶紝<span style="font-size: 11pt; font-family: 瀹嬩綋;">涓涓肩被鍨嬫垨鏄粨鏋勭被鍨?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鎴栨槸鏋氫婦綾誨瀷<br />錛?錛夊紩鐢ㄧ被鍨?br />錛?錛夋寚閽堢被鍨?br />鍊肩被鍨嬩笌</span><span style="font-size: 11pt; font-family: 瀹嬩綋;">寮曠敤綾誨瀷鐨勪笉鍚屽湪浜庯細</span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍊肩被鍨嬬殑鍙橀噺鐩存帴鍖呭惈鍏舵暟鎹?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鑰屽紩鐢ㄧ被鍨嬬殑鍙橀噺瀛樺偍瀵瑰叾鏁版嵁鐨勫紩鐢?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="1666616" class="Term"><span style="font-size: 11pt; font-family: "Times New Roman";" lang="EN-US">(reference)</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍚庤呯О涓哄璞?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="1116611" class="Term"><span style="font-size: 11pt; font-family: "Times New Roman";" lang="EN-US">(object)</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆傚浜庡紩鐢ㄧ被鍨?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">涓や釜鍙橀噺鍙兘寮曠敤鍚屼竴涓璞?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍥犳瀵逛竴涓彉閲忕殑鎿嶄綔鍙兘褰卞搷鍙︿竴涓彉閲忔墍寮曠敤鐨勫璞°傚浜庡肩被鍨嬶紝姣忎釜鍙橀噺閮芥湁鑷繁鐨勬暟鎹壇鏈紝瀵逛竴涓彉閲忕殑鎿嶄綔涓嶅彲鑳藉獎鍝嶅彟涓涓彉閲忋?br />浜屻傚肩被鍨?br /></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">1.鎵鏈夊肩被鍨嬩粠綾?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6611111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.ValueType</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">闅愬紡緇ф壙</span><span style="font-size: 11pt; font-family: 瀹嬩綋;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍚庤呭張浠庣被</span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6111666" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">object</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">緇ф壙銆備換浣曠被鍨嬮兘涓嶅彲鑳戒粠鍊肩被鍨嬫淳鐢熴?br /><br />2.</span><span style="font-family: 瀹嬩綋;">鎵鏈夊肩被鍨嬮兘闅愬紡澹版槑涓涓О涓洪粯璁ゆ瀯閫犲嚱鏁?/span><span style="font-family: 瀹嬩綋;"></span><span id="1166666" class="Term"><span lang="EN-US">(default constructor)</span></span><span style="font-family: 瀹嬩綋;" lang="EN-US"></span><span style="font-family: 瀹嬩綋;">鐨勫叕鍏辨棤鍙傛暟瀹炰緥鏋勯犲嚱鏁般傞粯璁ゆ瀯閫犲嚱鏁拌繑鍥炰竴涓浂鍒濆鍖栧疄渚?/span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">瀹冨氨鏄鍊肩被鍨嬬殑榛樿鍊?/span><span style="font-family: 瀹嬩綋;"></span><span id="6661611" class="Term"><span lang="EN-US">(default value)</span></span><span style="font-family: 瀹嬩綋;">錛?/span><p class="MsoListBullet" style=""><!--[if !supportLists]--><span style="font-family: Symbol;" lang="EN-US"><span style="">路<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬鎵鏈?/span><span style="font-family: 瀹嬩綋;"></span><span id="1616111" class="Production"><span lang="EN-US">simple-types</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊兼槸灝嗗叾鎵鏈変綅閮界疆闆剁殑浣嶆ā寮忔墍褰㈡垚鐨勫?/span><span style="font-family: 瀹嬩綋;">錛?/span></p><p class="MsoListBullet2" style="margin-left: 36pt; text-indent: -18.15pt;"><!--[if !supportLists]--><span style="font-family: "Courier New";" lang="EN-US"><span style="">o<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="6161111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">sbyte</span></span><span style="font-family: 瀹嬩綋;">銆?/span><span id="1611666" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">byte</span></span><span style="font-family: 瀹嬩綋;">銆?/span><span id="1666661" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">short</span></span><span style="font-family: 瀹嬩綋;">銆?/span><span id="6666116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">ushort</span></span><span style="font-family: 瀹嬩綋;">銆?/span><span id="1166616" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">int</span></span><span style="font-family: 瀹嬩綋;">銆?/span><span id="1611161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">uint</span></span><span style="font-family: 瀹嬩綋;">銆?/span><span id="1666161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">long</span></span><span style="font-family: 瀹嬩綋;" lang="EN-US"></span><span style="font-family: 瀹嬩綋;">鍜?/span><span style="font-family: 瀹嬩綋;"></span><span id="6161111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">ulong</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><span id="6611161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">0</span></span><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet2" style="margin-left: 36pt; text-indent: -18.15pt;"><!--[if !supportLists]--><span style="font-family: "Courier New";" lang="EN-US"><span style="">o<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="1166611" class="Codefragment"><span style="font-size: 10pt;">char</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><span id="1166161" class="Codefragment"><span style="font-size: 10pt;">'\x0000'</span></span><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet2" style="margin-left: 36pt; text-indent: -18.15pt;"><!--[if !supportLists]--><span style="font-family: "Courier New";" lang="EN-US"><span style="">o<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="6161116" class="Codefragment"><span style="font-size: 10pt;">float</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><st1:chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="F"><span id="6666666" class="Codefragment"><span style="font-size: 10pt;">0.0f</span></span></st1:chmetcnv><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet2" style="margin-left: 36pt; text-indent: -18.15pt;"><!--[if !supportLists]--><span style="font-family: "Courier New";" lang="EN-US"><span style="">o<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="1666611" class="Codefragment"><span style="font-size: 10pt;">double</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><span id="1166661" class="Codefragment"><span style="font-size: 10pt;">0.0d</span></span><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet2" style="margin-left: 36pt; text-indent: -18.15pt;"><!--[if !supportLists]--><span style="font-family: "Courier New";" lang="EN-US"><span style="">o<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="6166166" class="Codefragment"><span style="font-size: 10pt;">decimal</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><st1:chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="0" unitname="m"><span id="6661116" class="Codefragment"><span style="font-size: 10pt;">0.0m</span></span></st1:chmetcnv><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet2" style="margin-left: 36pt; text-indent: -18.15pt;"><!--[if !supportLists]--><span style="font-family: "Courier New";" lang="EN-US"><span style="">o<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="1111116" class="Codefragment"><span style="font-size: 10pt;">bool</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><span id="1111116" class="Codefragment"><span style="font-size: 10pt;">false</span></span><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet" style=""><!--[if !supportLists]--><span style="font-family: Symbol;" lang="EN-US"><span style="">路<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="1611116" class="Production"><span style="">enum-type</span></span><span style="font-family: 瀹嬩綋;"></span><span id="6166116" class="Codefragment"><span style="font-size: 10pt;">E</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊間負</span><span style="font-family: 瀹嬩綋;"></span><span id="6611666" class="Codefragment"><span style="font-size: 10pt;">0</span></span><span style="font-family: 瀹嬩綋;">銆?/span></p><p class="MsoListBullet" style=""><!--[if !supportLists]--><span style="font-family: Symbol;" lang="EN-US"><span style="">路<span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">聽聽聽聽聽聽聽聽 </span></span></span><!--[endif]--><span style="font-family: 瀹嬩綋;">瀵逛簬</span><span style="font-family: 瀹嬩綋;"></span><span id="1166116" class="Production"><span style="">struct-type</span></span><span style="font-family: 瀹嬩綋;">錛?/span><span style="font-family: 瀹嬩綋;">榛樿鍊兼槸閫氳繃灝嗘墍鏈夊肩被鍨嬪瓧孌佃緗負瀹冧滑鐨勯粯璁ゅ箋佸皢鎵鏈夊紩鐢ㄧ被鍨嬪瓧孌佃緗負</span><span style="font-family: 瀹嬩綋;"></span><span id="6116111" class="Codefragment"><span style="font-size: 10pt;">null</span></span><span style="font-family: 瀹嬩綋;"></span><span style="font-family: 瀹嬩綋;">鑰屼駭鐢熺殑鍊箋?/span></p> 3.C#涓湁鎵璋撶殑綆鍗曠被鍨嬫蹇碉紙simple type錛夛紝綾諱技浜巎ava鐨勫熀鏈被鍨嬶紝浣嗗張涓嶅悓錛孋#鐨勭畝鍗曠被鍨嬫湰璐ㄤ笂閮芥槸緇撴瀯綾誨瀷錛堥瀹氫箟闆嗗悎鐨勭粨鏋勭被鍨嬶級錛屾墍浠ヨ繕鏄肩被鍨嬶紝浠?span class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.ValueType</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US">緇ф壙鑰屾潵銆侰#鐨勭畝鍗曠被鍨嬪寘鎷細<br /></span><table class="MsoNormalTable" style="border: medium none ; margin-left: 12.5pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"><tbody><tr style=""><td style="border: 1pt solid windowtext; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><b><span style="font-family: 瀹嬩綋;">淇濈暀瀛?/span><span lang="EN-US"><o:p></o:p></span></b></p></td><td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><b><span style="font-family: 瀹嬩綋;">鍖栧悕鐨勭被鍨?/span><span lang="EN-US"><o:p></o:p></span></b></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1161111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">sbyte<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6611616" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.SByte<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1161666" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">byte<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="1116661" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Byte<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="6166116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">short<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="1166111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Int16<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1161111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">ushort<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6166111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.UInt16<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="6166611" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">int<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="1611111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Int32<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1111111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">uint<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6666661" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.UInt32<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="6111166" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">long<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6666616" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Int64<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1111116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">ulong<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6111161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.UInt64<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1666661" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">char<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="1111666" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Char<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1666161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">float<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="1166611" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Single<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="6611111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">double<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6666661" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Double<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="6166161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">bool<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="1616111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Boolean<o:p></o:p></span></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 109.9pt;" valign="top" width="147"><p class="Table"><span id="1611116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">decimal<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 189pt;" valign="top" width="252"><p class="Table"><span id="6616116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Decimal<o:p></o:p></span></span></p></td></tr></tbody></table> 榪欎簺綆鍗曠被鍨嬮兘鏄疭ystem鍛藉悕絀洪棿涓瀹氫箟緇撴瀯綾誨瀷鐨勫埆鍚嶏紙ruby鐨勫埆鍚嶅疄鍦ㄨ創(chuàng)蹇冿級<br /><br />4.鏋氫婦綾誨瀷錛?span style="font-size: 11pt; font-family: 瀹嬩綋;">鏋氫婦綾誨瀷鏄叿鏈夊懡鍚嶅父閲忕殑鐙壒鐨勭被鍨嬨傛瘡涓灇涓劇被鍨嬮兘鏈変竴涓熀紜綾誨瀷錛岃鍩虹綾誨瀷蹇呴』涓? </span><span id="1161111" class="Codefragment"><span style="font-size: 10pt;">byte</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?/span><span id="1661611" class="Codefragment"><span style="font-size: 10pt;">sbyte</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?/span><span id="6166161" class="Codefragment"><span style="font-size: 10pt;">short</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?/span><span id="6616116" class="Codefragment"><span style="font-size: 10pt;">ushort</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?/span><span id="6116116" class="Codefragment"><span style="font-size: 10pt;">int</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?/span><span id="1166611" class="Codefragment"><span style="font-size: 10pt;">uint</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?/span><span id="1616611" class="Codefragment"><span style="font-size: 10pt;">long</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"> 鎴?</span><span id="6611166" class="Codefragment"><span style="font-size: 10pt;">ulong</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆傚鏋滄病鏈変負鏋氫婦綾誨瀷涓殑鍏冪礌鎸囧畾鍩虹鍊鹼紝榛樿鏄粠0寮濮嬮愪竴閫掑銆?br /><br />涓夈傚紩鐢ㄧ被鍨?br /></span><p class="MsoNormal"><span style="font-family: 瀹嬩綋;">1.寮曠敤綾誨瀷鏄被綾誨瀷銆佹帴鍙g被鍨嬨佹暟緇勭被鍨嬫垨濮旀墭綾誨瀷銆?/span></p><p class="MsoNormal"><span style="font-family: 瀹嬩綋;">2.綾葷被鍨嬶細鍖呮嫭棰勫畾涔夌殑綾葷被鍨嬪拰鐢ㄦ埛閫氳繃class鍏抽敭瀛楃殑鑷畾涔夌被綾誨瀷</span></p><p class="MsoNormal"><span style="font-family: 瀹嬩綋;">3.瀵硅薄綾誨瀷錛?/span></p><p class="MsoNormal"><span id="1166611" class="Codefragment"><span style="font-size: 10pt; letter-spacing: 0.2pt;" lang="EN-US">object</span></span><span style="font-family: 瀹嬩綋; letter-spacing: 0.2pt;" lang="EN-US"></span><span style="font-family: 瀹嬩綋; letter-spacing: 0.2pt;">綾葷被鍨嬫槸鎵鏈夊叾浠栫被鍨嬬殑鏈緇堝熀綾匯?/span><span style="letter-spacing: 0.2pt;" lang="EN-US">C# </span><span style="font-family: 瀹嬩綋; letter-spacing: 0.2pt;" lang="EN-US"><span style="">聽</span>涓殑姣忕綾誨瀷閮芥槸鐩存帴鎴栭棿鎺ヤ粠</span><span style="font-family: 瀹嬩綋; letter-spacing: 0.2pt;"></span><span id="1616166" class="Codefragment"><span style="font-size: 10pt; letter-spacing: 0.2pt;" lang="EN-US">object</span></span><span style="font-family: 瀹嬩綋; letter-spacing: 0.2pt;" lang="EN-US"></span><span style="font-family: 瀹嬩綋; letter-spacing: 0.2pt;">綾葷被鍨嬫淳鐢熺殑銆?/span><span style="letter-spacing: 0.2pt;" lang="EN-US"><o:p></o:p></span></p><p class="MsoNormal"><span style="font-family: 瀹嬩綋;">鍏抽敭瀛?/span><span style="font-family: 瀹嬩綋;"></span><span id="1661611" class="Codefragment"><span style="font-size: 10pt;">object</span></span><span style="font-family: 瀹嬩綋;"></span><span style="font-family: 瀹嬩綋;">鍙槸棰勫畾涔夌被</span><span style="font-family: 瀹嬩綋;"></span><span id="1111611" class="Codefragment"><span style="font-size: 10pt;">System.Object</span></span><span style="font-family: 瀹嬩綋;"></span><span style="font-family: 瀹嬩綋;">鐨勫埆鍚嶃?/span></p> 4.string綾誨瀷:<br /><span id="6616661" class="Codefragment"><span style="font-size: 10pt;">string</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">綾誨瀷鏄洿鎺ヤ粠</span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6166116" class="Codefragment"><span style="font-size: 10pt;">object</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">緇ф壙鐨勫瘑灝佺被綾誨瀷銆?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍏抽敭瀛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6661611" class="Codefragment"><span style="font-size: 10pt;">string</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍙槸棰勫畾涔夌被</span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6616161" class="Codefragment"><span style="font-size: 10pt;">System.String</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鐨勫埆鍚?<br />5.鎺ュ彛綾誨瀷錛?br />涓巎ava涓殑鎺ュ彛姒傚康鍩烘湰涓鑷達紝鍙互鍙樼浉瀹炵幇澶氶噸緇ф壙銆?br /></span><table class="MsoNormalTable" style="border: medium none ; margin-left: 18pt; border-collapse: collapse;" border="1" cellpadding="0" cellspacing="0"><tbody><tr style=""><td style="border: 1pt solid windowtext; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><b><span style="font-family: 瀹嬩綋;">綾葷被鍨?/span></b><span lang="EN-US"><o:p></o:p></span></p></td><td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 1pt 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><b><span style="font-family: 瀹嬩綋;">璇存槑</span></b><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="6116616" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Object<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span style="font-family: 瀹嬩綋;">鎵鏈夊叾浠栫被鍨嬬殑鏈緇堝熀綾匯?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="6116661" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.String<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span lang="EN-US">C# </span><span style="font-family: 瀹嬩綋;" lang="EN-US"><span style="">聽</span>璇█鐨勫瓧絎︿覆綾誨瀷銆?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="6666161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.ValueType<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span style="font-family: 瀹嬩綋;">鎵鏈夊肩被鍨嬬殑鍩虹被銆?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="6161166" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Enum<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span style="font-family: 瀹嬩綋;">鎵鏈夋灇涓劇被鍨嬬殑鍩虹被銆?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="1111111" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Array<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span style="font-family: 瀹嬩綋;">鎵鏈夋暟緇勭被鍨嬬殑鍩虹被銆?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="6161166" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Delegate<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span style="font-family: 瀹嬩綋;">鎵鏈夊鎵樼被鍨嬬殑鍩虹被銆?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr><tr style=""><td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 1pt 1pt; padding: 0cm 5.4pt; width: 4cm;" valign="top" width="151"><p class="Table"><span id="1611116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">System.Exception<o:p></o:p></span></span></p></td><td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 1pt 1pt medium; padding: 0cm 5.4pt; width: 274.5pt;" valign="top" width="366"><p class="Table"><span style="font-family: 瀹嬩綋;">鎵鏈夊紓甯哥被鍨嬬殑鍩虹被銆?/span><span style="font-family: 瀹嬩綋;"></span><span lang="EN-US"><o:p></o:p></span></p></td></tr></tbody></table><br />鍥涖傝綆便佹媶綆辨蹇?br /><span style="font-size: 11pt; font-family: 瀹嬩綋;">1.瑁呯鍜屾媶綆辯殑姒傚康鏄?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: "Times New Roman";" lang="EN-US">C# </span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US"><span style="">聽</span>鐨勭被鍨嬬郴緇熺殑鏍稿績銆傚畠鍦?</span><span id="1616611" class="Production"><span style="font-size: 11pt;">value-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"> 鍜?</span><span id="1666661" class="Production"><span style="font-size: 11pt;">reference-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"> 涔嬮棿鐨勬灦璧蜂簡涓搴фˉ姊侊紝浣垮緱浠諱綍 </span><span id="6166116" class="Production"><span style="font-size: 11pt;">value-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"> 鐨勫奸兘鍙互杞崲涓?</span><span id="6661616" class="Codefragment"><span style="font-size: 10pt;">object</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"> 綾誨瀷鐨勫鹼紝鍙嶈繃鏉ヨ漿鎹篃鍙互銆?br />2.瑁呯錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">瑁呯杞崲鍏佽灝?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6161111" class="Production"><span style="font-size: 11pt;">value-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">闅愬紡杞崲涓?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="1661166" class="Production"><span style="font-size: 11pt;">reference-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?br />瑁呯鐨勮涓哄彲浠ョ敤涓嬮潰鐨勮繃紼嬫弿榪幫細<br /></span><p class="Code"><span lang="EN-US">sealed class T_Box: System.ValueType<br /> {<br /><span style=""></span>T value;</span></p><p class="Code"><span lang="EN-US"><span style=""></span></span><span style="" lang="DE">public T_Box(T t) {<br /><span style="">聽聽聽聽 </span>value = t;<br /><span style=""></span>}<br /> }<o:p></o:p></span></p><span style="font-size: 11pt; font-family: 瀹嬩綋; letter-spacing: -0.3pt;">鍒嗛厤涓涓璞″疄渚?/span><span style="font-size: 11pt; font-family: 瀹嬩綋; letter-spacing: -0.3pt;">錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋; letter-spacing: -0.3pt;">鐒跺悗灝?/span><span style="font-size: 11pt; font-family: 瀹嬩綋; letter-spacing: -0.3pt;"></span><span id="1161111" class="Production"><span style="font-size: 11pt; letter-spacing: -0.3pt;" lang="EN-US">value-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋; letter-spacing: -0.3pt;" lang="EN-US"></span><span style="font-size: 11pt; font-family: 瀹嬩綋; letter-spacing: -0.3pt;">鐨勫煎鍒跺埌璇ュ疄渚嬩腑<br />3.鎷嗙錛?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鎷嗙杞崲鍏佽灝?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6661616" class="Production"><span style="font-size: 11pt;">reference-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鏄懼紡杞崲涓?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="6161611" class="Production"><span style="font-size: 11pt;">value-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">銆?br /></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">浠庡璞?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="1611611" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">box</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鍒?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="1666611" class="Production"><span style="font-size: 11pt;" lang="EN-US">value-type</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US"></span><span id="6611116" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">T</span></span><span style="font-size: 11pt; font-family: 瀹嬩綋;" lang="EN-US"></span><span style="font-size: 11pt; font-family: 瀹嬩綋;">鐨勬媶綆辮漿鎹㈢浉褰撲簬鎵ц琛ㄨ揪寮?/span><span style="font-size: 11pt; font-family: 瀹嬩綋;"></span><span id="1161161" class="Codefragment"><span style="font-size: 10pt;" lang="EN-US">((T_Box)box).value</span></span><br /><img src ="http://www.tkk7.com/killme2008/aggbug/99418.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/killme2008/" target="_blank">dennis</a> 2007-02-12 12:30 <a href="http://www.tkk7.com/killme2008/archive/2007/02/12/99418.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>C#涓巎ava鐨勫紓鍚?/title><link>http://www.tkk7.com/killme2008/archive/2007/02/10/99151.html</link><dc:creator>dennis</dc:creator><author>dennis</author><pubDate>Sat, 10 Feb 2007 09:39:00 GMT</pubDate><guid>http://www.tkk7.com/killme2008/archive/2007/02/10/99151.html</guid><wfw:comment>http://www.tkk7.com/killme2008/comments/99151.html</wfw:comment><comments>http://www.tkk7.com/killme2008/archive/2007/02/10/99151.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/killme2008/comments/commentRss/99151.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/killme2008/services/trackbacks/99151.html</trackback:ping><description><![CDATA[聽聽聽 緗戜笂鍒板鍏呮枼榪檆#涓巎ava瀵規(guī)瘮鐨勬枃绔狅紝鐪嬩簡鐪嬶紝榪樻槸瑙夌殑MSDN涓婄殑涓綃囨枃绔犲緢鍏ㄩ潰鍜屽瑙傘傘?a >閽堝JAVA寮鍙戜漢鍛樼殑C#緙栫▼璇█</a>銆嬨?br /><br />聽聽聽 鎴戠殑絎竴澶〤#瀛︿範錛屾諱綋鎰熻C#鍦ㄨ璦灞傞潰涓婁繚鐣欎簡鏇村C++/C鐨勭壒鐐癸紝姣斿virtual,override鍏抽敭瀛楃殑浣跨敤錛屾瘮濡傜粨鏋勶紙鍊肩被鍨嬶紝瀛樺偍鍦ㄦ爤涓婏級錛屾瘮濡俤elegate錛堢被浼煎嚱鏁版寚閽堬級銆傛瘮杈冩劅鍏磋叮鐨勪篃灝辨槸delegate銆佷簨浠跺拰attribute鏂歸潰銆侰#鏌愮鎰忎箟涓婅姣攋ava紼嶅井澶嶆潅錛屾瘮C++綆鍗曘?br /><br />聽聽聽 鍙傜収璇█瑙勮寖鍐欑殑渚嬪瓙錛屾娊璞$被銆佺戶鎵跨殑渚嬪瓙錛屽彲浠ユ墿灞曟垚涓涓畝鍗曡綆楀櫒錛?br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System;<br /></span><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System.Collections;<br /><br /></span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">聽VirtualDemo<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Expression<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">abstract</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Evaluate(Hashtable聽vars);<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Constant聽:聽Expression<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽value;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Constant(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽value)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.value聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽value;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Evaluate(Hashtable聽vars)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽value;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽VariableReference聽:聽Expression<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽name;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽VariableReference(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽name)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.name聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽name;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Evaluate(Hashtable聽vars)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">object</span><span style="color: rgb(0, 0, 0);">聽value聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽vars[name];<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">if</span><span style="color: rgb(0, 0, 0);">聽(value聽</span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">null</span><span style="color: rgb(0, 0, 0);">)<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Exception(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Unknown聽variable:聽</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽name);<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽Convert.ToDouble(value);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Operation聽:聽Expression<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽Expression聽left;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">聽op;<br />聽聽聽聽聽聽聽聽Expression聽right;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Operation(Expression聽left,聽</span><span style="color: rgb(0, 0, 255);">char</span><span style="color: rgb(0, 0, 0);">聽op,聽Expression聽right)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.left聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽left;<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.op聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽op;<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.right聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽right;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">override</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Evaluate(Hashtable聽vars)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽left.Evaluate(vars);<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽y聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽right.Evaluate(vars);<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">switch</span><span style="color: rgb(0, 0, 0);">聽(op)<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">case</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">:聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">聽y;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">case</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">:聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 0);">聽y;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">case</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">:聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽y;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">case</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">:聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">/</span><span style="color: rgb(0, 0, 0);">聽y;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">throw</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Exception(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Unknown聽operator</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Test<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Main(</span><span style="color: rgb(0, 0, 255);">string</span><span style="color: rgb(0, 0, 0);">聽[]args)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽Expression聽e聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Operation(<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽VariableReference(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">x</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">),<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Operation(<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽VariableReference(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">),<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">'</span><span style="color: rgb(0, 0, 0);">,<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Constant(</span><span style="color: rgb(0, 0, 0);">2</span><span style="color: rgb(0, 0, 0);">)<br />聽聽聽聽聽聽聽聽聽聽聽聽)<br />聽聽聽聽聽聽聽聽);<br />聽聽聽聽聽聽聽聽Hashtable聽vars聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Hashtable();<br />聽聽聽聽聽聽聽聽vars[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">x</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">3</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽vars[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">5</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽Console.WriteLine(e.Evaluate(vars));聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽Outputs聽"21"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);">聽聽聽聽聽聽聽聽vars[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">x</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">1.5</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽vars[</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">y</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">9</span><span style="color: rgb(0, 0, 0);">;<br />聽聽聽聽聽聽聽聽Console.WriteLine(e.Evaluate(vars));聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">聽Outputs聽"16.5"</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 0, 0);"><br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />}<br /></span></div><br />鍐嶆潵涓涓鎵樼殑渚嬪瓙錛屽嚱鏁頒綔涓哄彉閲忕殑浼犻掑拰浣跨敤錛屽鏈塁++緇忛獙鎴栬呭姩鎬佽璦緇忛獙鐨勪漢鏉ヨ涓嶄細濂囨細<br /><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 0, 255);">using</span><span style="color: rgb(0, 0, 0);">聽System;<br /></span><span style="color: rgb(0, 0, 255);">namespace</span><span style="color: rgb(0, 0, 0);">聽DelegateDemo<br />{<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">delegate</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Function(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x);<br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Multiplier<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽factor;<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽Multiplier(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽factor)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.factor聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽factor;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Multiply(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽factor;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">聽Test<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽Square(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽x)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽x聽</span><span style="color: rgb(0, 0, 0);">*</span><span style="color: rgb(0, 0, 0);">聽x;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽Apply(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽a,聽Function聽f)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽result聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[a.Length];<br />聽聽聽聽聽聽聽聽聽聽聽 //鐩存帴閫氳繃f()璋冪敤<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);">聽i聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 0);">0</span><span style="color: rgb(0, 0, 0);">;聽i聽</span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">聽a.Length;聽i</span><span style="color: rgb(0, 0, 0);">++</span><span style="color: rgb(0, 0, 0);">)聽result[i]聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽f(a[i]);<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);">聽result;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);">聽Main()<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽a聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽{聽</span><span style="color: rgb(0, 0, 0);">0.0</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">0.5</span><span style="color: rgb(0, 0, 0);">,聽</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">聽};<br />聽聽聽聽聽聽聽聽聽聽聽 //delegate Function鍒嗗埆璧嬩簣浜嗕笉鍚岀殑鏂規(guī)硶<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽squares聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Apply(a,聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Function(Square));<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽sines聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Apply(a,聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Function(Math.Sin));<br />聽聽聽聽聽聽聽聽聽聽聽聽Multiplier聽m聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Multiplier(</span><span style="color: rgb(0, 0, 0);">2.0</span><span style="color: rgb(0, 0, 0);">);<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">[]聽doubles聽</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">聽Apply(a,聽</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);">聽Function(m.Multiply));<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="color: rgb(0, 0, 255);">foreach</span><span style="color: rgb(0, 0, 0);">聽(</span><span style="color: rgb(0, 0, 255);">double</span><span style="color: rgb(0, 0, 0);">聽b聽</span><span style="color: rgb(0, 0, 255);">in</span><span style="color: rgb(0, 0, 0);">聽doubles)<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽Console.WriteLine(b);<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽}<br /><br />聽聽聽聽}<br />}<br /></span></div><br /><img src ="http://www.tkk7.com/killme2008/aggbug/99151.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/killme2008/" target="_blank">dennis</a> 2007-02-10 17:39 <a href="http://www.tkk7.com/killme2008/archive/2007/02/10/99151.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鎴戠殑絎竴涓狢#紼嬪簭http://www.tkk7.com/killme2008/archive/2007/02/09/98934.htmldennisdennisFri, 09 Feb 2007 02:38:00 GMThttp://www.tkk7.com/killme2008/archive/2007/02/09/98934.htmlhttp://www.tkk7.com/killme2008/comments/98934.htmlhttp://www.tkk7.com/killme2008/archive/2007/02/09/98934.html#Feedback0http://www.tkk7.com/killme2008/comments/commentRss/98934.htmlhttp://www.tkk7.com/killme2008/services/trackbacks/98934.html
using聽System;

publicclass聽HelloWorld
{
聽聽聽聽
publicstaticvoid聽Main()
聽聽聽聽{
聽聽聽聽聽聽聽聽Console.WriteLine(
"Hello聽World");
聽聽聽聽}

聽聽聽聽
}

聽聽聽 瀛樹負hello.cs銆傞厤緗ソ鐜鍙橀噺錛屽湪鍛戒護琛岃繍琛?csc hello.cs銆傚湪鐩綍涓嬩細鐢熸垚涓涓猦ello.exe,鐩存帴榪愯hello銆傛墦鍗幫細
Hello聽World

聽聽聽 鐪嬭搗鏉ヨ窡java紜疄娌′粈涔堜笉鍚岋紝闄や簡瀛楁瘝鐨勫ぇ灝忓啓錛屽拰java榛樿寮曞叆java.lang鍖咃紝鑰岃繖閲岄渶瑕乽sing System;
聽聽聽 紼嶅井澶嶆潅鐐圭殑渚嬪瓙錛屾垜浠啓涓涓簱鏂囦歡stack.dll錛屾垨鑰呰涓涓▼搴忛泦錛坖ava涓寘鐨勬蹇碉級錛?br />
using聽System;

namespace聽Acme.Collections
{
聽聽聽聽
publicclass聽Stack
聽聽聽聽{
聽聽聽聽聽聽聽聽Entry聽top;
聽聽聽聽聽聽聽聽
publicvoid聽push(object聽data)
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽top聽
=new聽Entry(top,聽data);
聽聽聽聽聽聽聽聽聽聽

聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
publicobject聽pop()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
if聽(top聽==null)聽thrownew聽InvalidOperationException();
聽聽聽聽聽聽聽聽聽聽聽聽
object聽result聽=聽top.data;
聽聽聽聽聽聽聽聽聽聽聽聽top聽
=聽top.next;
聽聽聽聽聽聽聽聽聽聽聽聽
return聽result;

聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
public聽Stack()
聽聽聽聽聽聽聽聽{
聽聽聽聽聽

聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽
class聽Entry
聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽
public聽Entry聽next;
聽聽聽聽聽聽聽聽聽聽聽聽
publicobject聽data;
聽聽聽聽聽聽聽聽聽聽聽聽
public聽Entry(Entry聽next,聽object聽data)
聽聽聽聽聽聽聽聽聽聽聽聽{
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
this.next聽=聽next;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
this.data聽=聽data;
聽聽聽聽聽聽聽聽聽聽聽聽}
聽聽聽聽聽聽聽聽}
聽聽聽聽}
}

聽聽聽 浠g爜寰堟槑鏄撅紝涓涓畝鍗曠殑鏍堢粨鏋勶紝鎴戜滑鎶奡tack綾繪斁鍦ㄥ懡鍚嶇┖闂?span style="color: rgb(0, 0, 0);">Acme.Collections涓?/span>榪愯錛歝sc /t:library stack.cs錛屽湪搴旂敤鐩綍涓嬬敓鎴愪竴涓猻tack.dll銆傛垜浠庝箞璋冪敤榪欎釜閾炬帴搴撳憿錛熷啓涓祴璇曠被錛?br />
using聽System;
using聽Acme.Collections;
publicclass聽Test
{
聽聽聽聽
publicstaticvoid聽Main()
聽聽聽聽{
聽聽聽聽聽聽聽聽Stack聽stack聽
=new聽Stack();
聽聽聽聽聽聽聽聽stack.push(
1);
聽聽聽聽聽聽聽聽stack.push(
10);
聽聽聽聽聽聽聽聽stack.push(
100);
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽
聽聽聽聽聽聽聽聽Console.WriteLine(stack.pop());
聽聽聽聽聽聽聽聽Console.WriteLine(stack.pop());
聽聽聽聽聽聽聽聽Console.WriteLine(stack.pop());
聽聽聽聽}
}

聽聽聽 寰堟槑鏄撅紝鍙槸鎶妀ava鐨刬mport鎹㈡垚浜唘sing錛岃屼笖涓嶉渶瑕侀氶厤絎︺傜紪璇憈est.cs:csc /r:stack.dll test.cs銆?br />聽聽聽 C#鍜宺uby灝嗘槸鎴?7騫翠富瑕佺殑瀛︿範璁″垝錛屽彟澶栧氨鏄疛2EE娣卞叆鎶鏈柟闈㈢殑鎺屾彙鍜岀悊瑙?鐗瑰埆鏄ā寮忋佸伐浣滄祦鍜孭ortal鏂歸潰銆?br />



dennis 2007-02-09 10:38 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 日本三级2019在线观看免费| 免费jjzz在线播放国产| 国产亚洲成人久久| 亚洲午夜无码久久久久软件| 久久精品国产免费| 亚洲高清国产拍精品青青草原 | 亚洲精品二三区伊人久久| 精品国产福利尤物免费| 浮力影院第一页小视频国产在线观看免费| 国产AV无码专区亚洲精品| 色噜噜的亚洲男人的天堂| 成年人视频免费在线观看| 久久精品国产亚洲麻豆| 无码人妻一区二区三区免费视频| 24小时日本在线www免费的| 老汉色老汉首页a亚洲| 国产久爱免费精品视频 | 亚洲无线一二三四区手机| 亚洲欧美一区二区三区日产| 亚洲视频在线观看免费视频| 国产亚洲婷婷香蕉久久精品| 日日摸夜夜添夜夜免费视频| 日本高清免费aaaaa大片视频| 亚洲另类小说图片| 午夜视频免费在线观看| 国产精一品亚洲二区在线播放| 免费人成视频在线播放| 日本特黄特黄刺激大片免费| 亚洲综合偷自成人网第页色| 久久久久久精品成人免费图片| 亚洲VA中文字幕不卡无码| 好猛好深好爽好硬免费视频| 免费人成在线观看网站视频| 亚洲AV日韩AV一区二区三曲| 好吊妞在线成人免费| 亚洲欧洲另类春色校园网站| 国产1024精品视频专区免费| 亚洲性一级理论片在线观看| 中文字幕在线观看免费视频| 久久亚洲私人国产精品| 95免费观看体验区视频|