{"id":61,"date":"2008-02-11T03:33:01","date_gmt":"2008-02-11T03:33:01","guid":{"rendered":""},"modified":"2008-02-11T03:33:01","modified_gmt":"2008-02-11T03:33:01","slug":"61","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=61","title":{"rendered":"C#\u4e2d\u65b9\u6cd5\u7684\u53c2\u6570\u6709\u56db\u79cd\u7c7b\u578b"},"content":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;C\uff03\u4e2d\u65b9\u6cd5\u7684\u53c2\u6570\u6709\u56db\u79cd\u7c7b\u578b\uff1a<\/p>\n<p>&nbsp;&nbsp;\uff0d\u503c\u53c2\u6570\uff1a\u4e0d\u542b\u4efb\u4f55\u4fee\u9970\u7b26\u3002\u65b9\u6cd5\u4e2d\u7684\u5f62\u53c2\u662f\u5b9e\u53c2\u7684\u4e00\u4efd\u62f7\u8d1d\uff0c\u5f62\u53c2\u7684\u6539\u53d8\u4e0d\u4f1a\u5f71\u54cd\u5230\u5185\u5b58\u4e2d\u5b9e\u53c2\u7684\u7684\u503c\uff0c\u5b9e\u53c2\u662f\u5b89\u5168\u7684\u3002<\/p>\n<p>&nbsp;&nbsp;\uff0d\u5f15\u7528\u53c2\u6570\uff1a\u4ee5ref\u4fee\u9970\u7b26\u58f0\u660e\u3002\u4f20\u9012\u7684\u53c2\u6570\u5b9e\u9645\u4e0a\u662f\u5b9e\u53c2\u7684\u6307\u9488\uff0c\u6240\u4ee5\u5728\u65b9\u6cd5\u4e2d\u7684\u64cd\u4f5c\u90fd\u662f\u76f4\u63a5\u5bf9\u5b9e\u53c2\u8fdb\u884c\u7684\uff0c\u800c\u4e0d\u662f\u590d\u5236\u4e00\u4e2a\u503c\uff1b\u53ef\u4ee5\u5229\u7528\u8fd9\u4e2a\u65b9\u5f0f\u5728\u65b9\u6cd5\u8c03\u7528\u65f6\u53cc\u5411\u4f20\u9012\u53c2\u6570\uff1b\u4e3a\u4e86\u4ee5ref\u65b9\u5f0f\u4f7f\u7528\u53c2\u6570\uff0c\u5fc5\u987b\u5728\u65b9\u6cd5\u58f0\u660e\u548c\u65b9\u6cd5\u8c03\u7528\u4e2d\u90fd\u660e\u786e\u5730\u6307\u5b9aref\u5173\u952e\u5b57\uff0c\u5e76\u4e14\u5b9e\u53c2\u53d8\u91cf\u5728\u4f20\u9012\u7ed9\u65b9\u6cd5\u524d\u5fc5\u987b\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n<p>&nbsp;&nbsp;\uff0d\u8f93\u51fa\u53c2\u6570\uff1a\u4ee5out\u4fee\u9970\u7b26\u58f0\u660e\u3002\u548cref\u7c7b\u4f3c\uff0c\u5b83\u4e5f\u662f\u76f4\u63a5\u5bf9\u5b9e\u53c2\u8fdb\u884c\u64cd\u4f5c\u3002\u5728\u65b9\u6cd5\u58f0\u660e\u548c\u65b9\u6cd5\u8c03\u7528\u65f6\u90fd\u5fc5\u987b\u660e\u786e\u5730\u6307\u5b9aout\u5173\u952e\u5b57\u3002out\u53c2\u6570\u58f0\u660e\u65b9\u5f0f\u4e0d\u8981\u6c42\u53d8\u91cf\u4f20\u9012\u7ed9\u65b9\u6cd5\u524d\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u56e0\u4e3a\u5b83\u7684\u542b\u4e49\u53ea\u662f\u7528\u4f5c\u8f93\u51fa\u76ee\u7684\u3002\u4f46\u662f\uff0c\u5728\u65b9\u6cd5\u8fd4\u56de\u524d\uff0c\u5fc5\u987b\u5bf9out\u53c2\u6570\u8fdb\u884c\u8d4b\u503c\u3002<\/p>\n<p>&nbsp;&nbsp;\uff0d\u6570\u7ec4\u578b\u53c2\u6570\uff1a\u4ee5params\u4fee\u9970\u7b26\u58f0\u660e\u3002params\u5173\u952e\u5b57\u7528\u6765\u58f0\u660e\u53ef\u53d8\u957f\u5ea6\u7684\u53c2\u6570\u5217\u8868\u3002\u65b9\u6cd5\u58f0\u660e\u4e2d\u53ea\u80fd\u5305\u542b\u4e00\u4e2aparams\u53c2\u6570\u3002<\/p>\n<p><code><br \/>using System;<br \/>class Test<br \/>{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void F(params int[] args)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(\"Array contains {0} elements:\",args.Length);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach(int i in args)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Console.Write(\"{0}\",i);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static void Main()<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int [] a = {1,2,3};<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F(a);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F(10,20,30,40);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F();<br \/>}<br \/>}<br \/><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;C\uff03\u4e2d\u65b9\u6cd5\u7684\u53c2\u6570\u6709\u56db&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-NET"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}