{"id":2052,"date":"2021-09-20T02:56:35","date_gmt":"2021-09-19T18:56:35","guid":{"rendered":"https:\/\/www.develop-note.com\/blog\/?p=2052"},"modified":"2022-02-16T21:46:20","modified_gmt":"2022-02-16T13:46:20","slug":"loop-foreach-while","status":"publish","type":"post","link":"https:\/\/www.develop-note.com\/blog\/2021\/09\/20\/loop-foreach-while\/","title":{"rendered":"D-25-\u8ff4\u5708 loop ? foreach ? while"},"content":{"rendered":"<h1>\u8ff4\u5708 loop<\/h1>\n<p>\u6628\u5929\u5c0f\u5149\u66f4\u9032\u4e00\u6b65\u7684\u8a8d\u8b58\u4e86\u908f\u8f2f\u5224\u65b7\u5f0f\uff0c\u4e5f\u958b\u59cb\u81ea\u5df1\u958b\u767c\u4e86\u4e00\u500b\u5fc3\u60c5\u986f\u793a\u5668\uff0c\u4e0d\u904e\u5982\u679c\u8981\u8868\u73fe10\u500b\u4eba\u7684\u5fc3\u60c5\u8a72\u5982\u4f55\u8655\u7406\u5462\uff0c\u8acb\u5927\u5bb6\u518d\u770b\u4e0b\u53bb\u5427\u3002<\/p>\n<p><!--more--><\/p>\n<h2>\u6068\u4e0d\u5f97\u6709\u5341\u96d9\u624b<\/h2>\n<p>\u300c\u524d\u8f29\u65e9\uff0c\u4eca\u5929\u8981\u958b\u767c\u4ec0\u9ebc\u529f\u80fd\u5462\uff1f\u300d<br \/>\n\u5c0f\u5149\u4e00\u5230\u516c\u53f8\u4e00\u5982\u5f80\u6614\u7684\u5c0d\u5927\u982d\u6253\u62db\u547c\uff0c\u800c\u5927\u982d\u4e00\u5982\u5f80\u6614\u7684\u57cb\u9996\u65bc\u6587\u4ef6\u5806\u4e4b\u4e2d\uff0c\u8207\u6628\u65e5\u4e0d\u540c\u7684\u662f\u5169\u96bb\u773c\u775b\u591a\u4e86\u5f88\u6df1\u7684\u9ed1\u773c\u5708\u3002<br \/>\n\u300c\u524d\u8f29\u4f60\u9084\u597d\u55ce\uff1f\u300d<br \/>\n\u300c\u5509\uff5e\u6211\u6068\u4e0d\u5f97\u6709\u5341\u500b\u6211\u4f86\u5e6b\u5fd9\u958b\u767c\u3002\u300d<br \/>\n\u5927\u982d\u5c0d\u5c0f\u5149\u8aaa\u5b8c\u5f8c\u6253\u4e86\u4e00\u500b\u5927\u54c8\u6b20\uff0c\u611f\u89ba\u662f\u597d\u5e7e\u5929\u6c92\u6709\u597d\u597d\u7761\u89ba\u7684\u6a23\u5b50\uff0c\u5c0f\u5149\u770b\u5230\u5f8c\u5fc3\u88e1\u60f3\u8457\u6211\u8a72\u600e\u9ebc\u5e6b\u4e0a\u5fd9\u3002<br \/>\n\u300c\u524d\u8f29\uff0c\u6709\u4ec0\u9ebc\u6211\u80fd\u5e6b\u5fd9\u7684\u55ce\uff1f\u300d<br \/>\n\u5c0f\u5149\u8aaa\u5b8c\u4e4b\u5f8c\u5927\u982d\u8a8d\u771f\u7684\u60f3\u4e00\u60f3\u5f8c\u7a81\u7136\u9593\u50cf\u662f\u88ab\u96f7\u6253\u5230\u4e00\u6a23\uff0c\u6240\u4ee5\u4ed6\u5c31\u5c0d\u5c0f\u5149\u9019\u9ebc\u8aaa\u3002<br \/>\n\u300c\u4f86\u5427\uff0c\u5e6b\u6211\u5beb\u5341\u500b\u52a0\u6cb9\uff0c\u7528\u7a0b\u5f0f\u5beb\u300d<br \/>\n\u5c0f\u5149\u807d\u5230\u5f8c\u5f88\u52aa\u529b\u7684\u958b\u59cb\u5beb\uff0c\u56e0\u70ba\u60f3\u8aaa\u524d\u8f29\u51fa\u500b\u4ed6\u80fd\u5920\u5beb\u7684\u6771\u897f\u6240\u4ee5\u8981\u597d\u597d\u8868\u73fe\uff0c\u4e0d\u904e\u904e\u4e86\u4e09\u5206\u9418\u5927\u982d\u5c31\u554f\u8aaa\u5beb\u597d\u6c92\uff0c\u9019\u8b93\u5c0f\u5149\u7684\u81ea\u4fe1\u5fc3\u5927\u53d7\u6253\u64ca\uff0c\u6240\u4ee5\u4ed6\u5c31\u9019\u9ebc\u5c0d\u5927\u982d\u8aaa\u3002<br \/>\n\u300c\u524d\u8f29\u6211\u7684\u624b\u901f\u4e0d\u5920\u5feb\uff0c\u5c31\u7b97\u662f<code>ctrl<\/code>+<code>v<\/code>\u6211\u4e5f\u624d\u6253\u4e86\u4e5d\u500b\u52a0\u6cb9\u800c\u5df2\u3002\u300d<br \/>\n\u5927\u982d\u807d\u5230\u5c31\u54c8\u54c8\u5927\u7b11\uff0c\u4e26\u4e14\u908a\u64e6\u7b11\u51fa\u4f86\u7684\u773c\u6dda\u908a\u8ddf\u5c0f\u5149\u9019\u9ebc\u8aaa\u3002<br \/>\n\u300c\u54c8\u54c8\u54c8\uff0c\u4e0d\u597d\u610f\u601d\u56e0\u70ba\u8981\u6559\u7d66\u4f60\u65b0\u6771\u897f\u6240\u4ee5\u8003\u9a57\u4f60\u4e00\u4e0b\uff0c\u4f86\u5427\u6211\u5011\u4f86\u5b78\u7fd2\u8ff4\u5708\u5427\u3002\u300d<\/p>\n<h2>\u8ff4\u5708 loop<\/h2>\n<p>\u8ff4\u5708\u6709\u5169\u7a2e<code>for<\/code>\u8ddf<code>while<\/code>\uff0c\u4f46\u662f\u5176\u5be6\u9084\u6709\u4e00\u7a2e\u662f<code>foreach<\/code>\u63a5\u4e0b\u4f86\u91dd\u5c0d\u9019\u4e9b\u5167\u5bb9\u8ddf\u5927\u5bb6\u8aaa\u660e\u4e00\u4e0b\u3002<\/p>\n<h3>for<\/h3>\n<p><code>for<\/code>\u8ff4\u5708\u7c21\u55ae\u8aaa\u5c31\u662f\u5f9e\u4e00\u500b\u958b\u59cb\u5f0f\u5b50\u8ddf\u4e00\u500b\u7d50\u675f\u5f0f\u5b50\u9084\u6709\u4e00\u500b\u9084\u6c92\u7d50\u675f\u7684\u5f0f\u5b50\u6240\u7d44\u6210\uff0c\u7136\u5f8c\u518d\u7d50\u675f\u7684\u5f0f\u5b50\u9084\u6c92\u6210\u7acb\u6642\u6703\u57f7\u884c\u5340\u584a\u5167\u7684\u7a0b\u5f0f\uff0c\u6240\u4ee5\u7c21\u55ae\u5beb\u5c31\u5982\u4e0b\u9762\u7684\u6a23\u5b50\u3002<\/p>\n<pre><code class=\"language-cs\">for(var i = 0; i &lt; 10; i++)\n{\n    Console.WriteLine(&quot;\u52a0\u6cb9&quot;);\n}<\/code><\/pre>\n<h3>while<\/h3>\n<p><code>while<\/code>\u8ff4\u5708\u5247\u662f\u7576\u5f0f\u5b50\u4e0d\u6210\u7acb\u7684\u72c0\u6cc1\u4e0b\u6703\u57f7\u884c\u5340\u584a\u5167\u7684\u7a0b\u5f0f\uff0c\u6240\u4ee5\u5f0f\u5b50\u5beb\u8d77\u4f86\u5982\u4e0b\u6240\u793a\u3002<\/p>\n<pre><code class=\"language-csharp\">var i = 0;\nwhile(i &lt; 10)\n{\n    Console.WriteLine(&quot;\u52a0\u6cb9&quot;);\n    i++;\n}<\/code><\/pre>\n<h2>\u5f8c\u8a18<\/h2>\n<p>\u300c\u597d\u56c9\uff0c\u5169\u7a2e\u8ff4\u5708\u7684\u65b9\u5f0f\u90fd\u544a\u8a34\u4f60\u56c9\uff0c\u4f60\u5225\u5728\u50bb\u50bb\u7684\u7528<code>ctrl<\/code>+<code>v<\/code>\u4f86\u5beb\u7a0b\u5f0f\u56c9\u3002\u300d<br \/>\n\u6559\u5b8c\u5c0f\u5149\u5f8c\u5927\u982d\u9019\u9ebc\u8ddf\u5c0f\u5149\u8aaa\uff0c\u5c0f\u5149\u5148\u662f\u4e0d\u597d\u610f\u601d\u7684\u6293\u6293\u982d\uff0c\u4f46\u662f\u537b\u7a81\u7136\u60f3\u8d77\u67d0\u4ef6\u4e8b\u60c5\u7684\u9019\u9ebc\u8aaa\u3002<br \/>\n\u300c\u524d\u8f29\u4f60\u662f\u4e0d\u662f\u9084\u6709<code>foreach<\/code>\u6c92\u6559\u554a\u3002\u300d<br \/>\n\u300c\u54c8\u54c8\u54c8\uff0c\u4f60\u771f\u7684\u6709\u8a8d\u771f\u5728\u807d\u6211\u8aaa\uff0c\u9019\u500b\u6771\u897f\u660e\u5929\u518d\u6559\u4f60\u3002\u300d<br \/>\n\u70ba\u4ec0\u9ebc\u8981\u660e\u5929\u6559\u5462\uff0c\u7576\u7136\u662f\u656c\u8acb\u671f\u5f85\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8ff4\u5708 loop \u6628\u5929\u5c0f\u5149\u66f4\u9032\u4e00\u6b65\u7684\u8a8d\u8b58\u4e86\u908f\u8f2f\u5224\u65b7\u5f0f\uff0c\u4e5f\u958b\u59cb\u81ea\u5df1\u958b\u767c\u4e86\u4e00\u500b\u5fc3\u60c5\u986f\u793a\u5668\uff0c\u4e0d\u904e\u5982\u679c\u8981\u8868\u73fe10\u500b\u4eba\u7684\u5fc3 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.develop-note.com\/blog\/2021\/09\/20\/loop-foreach-while\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587<span class=\"screen-reader-text\">\u3008D-25-\u8ff4\u5708 loop ? foreach ? while\u3009<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[90,71,92],"class_list":["post-2052","post","type-post","status-publish","format-standard","hentry","category-develop","tag-2021ironman","tag-c","tag-dotnetcore"],"_links":{"self":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/2052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/comments?post=2052"}],"version-history":[{"count":15,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/2052\/revisions"}],"predecessor-version":[{"id":2945,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/posts\/2052\/revisions\/2945"}],"wp:attachment":[{"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/media?parent=2052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/categories?post=2052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.develop-note.com\/blog\/wp-json\/wp\/v2\/tags?post=2052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}