{"id":143741,"date":"2019-05-05T09:35:08","date_gmt":"2019-05-05T01:35:08","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=143741"},"modified":"2019-04-26T15:37:26","modified_gmt":"2019-04-26T07:37:26","slug":"csharp-study-third","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/csharp-study-third.html","title":{"rendered":"c# \u7f16\u7a0b\u5b66\u4e60\uff08\u4e09\uff09"},"content":{"rendered":"
\u65b9\u6cd5\u662f\u5177\u540d\u7684\u8bed\u53e5\u5e8f\u5217<\/strong><\/div>\n
\r\n
returnType\u00a0methodName\u00a0(\u00a0parameterList\u00a0)<\/div>\r\n{\r\n\u00a0\/\/\u00a0\u8fd9\u91cc\u6dfb\u52a0\u65b9\u6cd5\u4e3b\u4f53\u8bed\u53e5\r\n}\r\n<\/pre>\n
    \n
  • \u00a0returnType(\u8fd4\u56de\u7c7b\u578b)\u662f\u7c7b\u578b\u540d\u79f0\uff0c\u6307\u5b9a\u65b9\u6cd5\u8fd4\u56de\u7684\u6570\u636e\u7c7b\u578b\u3002\u53ef\u4ee5\u662f\u4efb\u4f55\u7c7b\u578b\uff0c\u00a0\u5982\u00a0int\u00a0\u6216\u00a0string\u3002\u8981\u5199\u4e0d\u8fd4\u56de\u503c\u7684\u65b9\u6cd5\uff0c\u5fc5\u987b\u7528\u5173\u952e\u5b57\u00a0void\u00a0\u53d6\u4ee3\u00a0returnType\u3002<\/li>\n
  • methodName(\u65b9\u6cd5\u540d)\u662f\u8c03\u7528\u65b9\u6cd5\u65f6\u6240\u7528\u7684\u540d\u79f0\u3002\u65b9\u6cd5\u540d\u548c\u53d8\u91cf\u540d\u9075\u5faa\u76f8\u540c\u7684\u6807\u8bc6\u7b26\u547d\u540d\u89c4\u5219\u3002\u4f8b\u5982\uff0caddValues\u00a0\u662f\u6709\u6548\u65b9\u6cd5\u540d\uff0c\u800c\u00a0add$Values\u00a0\u4e0d\u662f\u3002\u5e94\u8be5\u4e3a\u65b9\u6cd5\u00a0\u540d\u91c7\u7528\u00a0camelCase\u00a0\u547d\u540d\u98ce\u683c\uff0c\u4f8b\u5982\u00a0displayCustomer(\u663e\u793a\u5ba2\u6237)\u3002<\/li>\n
  • parameterList(\u53c2\u6570\u5217\u8868)\u662f\u53ef\u9009\u7684\uff0c\u63cf\u8ff0\u4e86\u5141\u8bb8\u4f20\u7ed9\u65b9\u6cd5\u7684\u6570\u636e\u7684\u7c7b\u578b\u548c\u540d\u79f0\u3002\u5728\u00a0\u5706\u62ec\u53f7\u5185\u586b\u5199\u53c2\u6570\u5217\u8868\u65f6\uff0c\u8981\u50cf\u58f0\u660e\u53d8\u91cf\u90a3\u6837\uff0c\u5148\u5199\u7c7b\u578b\u540d\uff0c\u518d\u5199\u53c2\u6570\u540d\u3002\u4e24\u4e2a\u00a0\u6216\u66f4\u591a\u53c2\u6570\u5fc5\u987b\u4ee5\u9017\u53f7\u5206\u9694\u3002\u65b9\u6cd5\u4e3b\u4f53\u8bed\u53e5\u662f\u8c03\u7528\u65b9\u6cd5\u65f6\u8981\u6267\u884c\u7684\u4ee3\u7801\u3002\u5fc5\u987b\u653e\u5230\u8d77\u59cb\u5927\u62ec\u53f7({)\u4e0e\u7ed3\u675f\u5927\u62ec\u53f7\u00a0(})\u4e4b\u95f4<\/li>\n<\/ul>\n
      \n
    • C#\u4e0d\u652f\u6301\u5168\u5c40\u65b9\u6cd5\u3002\u6240\u6709\u65b9\u00a0\u6cd5\u5fc5\u987b\u5728\u7c7b\u7684\u5185\u90e8\uff0c\u5426\u5219\u4ee3\u7801\u65e0\u6cd5\u7f16\u8bd1\u3002<\/li>\n
    • \u5fc5\u987b\u663e\u5f0f\u6307\u5b9a\u53c2\u6570\u7c7b\u578b\u548c\u65b9\u6cd5\u8fd4\u56de\u7c7b\u578b\u3002\u4e0d\u80fd\u4f7f\u7528\u00a0var\u00a0\u5173\u952e\u5b57\u3002<\/li>\n
    • \u5982\u679c\u5e0c\u671b\u65b9\u6cd5\u8fd4\u56de\u6570\u636e(\u8fd4\u56de\u7c7b\u578b\u4e0d\u662f\u00a0void)\uff0c\u5fc5\u987b\u5728\u65b9\u6cd5\u5185\u90e8\u5199\u00a0return\u00a0\u8bed\u53e5\u3002\u8868\u8fbe\u5f0f\u7684\u7c7b\u578b\u5fc5\u987b\u4e0e\u65b9\u6cd5\u00a0\u6307\u5b9a\u7684\u8fd4\u56de\u7c7b\u578b\u76f8\u540c\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5047\u5982\u51fd\u6570\u8fd4\u56de\u00a0int\u00a0\u503c\uff0c\u5219\u00a0return\u00a0\u8bed\u53e5\u5fc5\u987b\u8fd4\u56de\u00a0int\uff0c\u5426\u5219\u7a0b\u5e8f\u65e0\u6cd5\u8fd0\u884c\u3002<\/li>\n
    • return\u00a0\u901a\u5e38\u653e\u5230\u65b9\u6cd5\u5c3e\u90e8\uff0c\u56e0\u4e3a\u5b83\u5bfc\u81f4\u65b9\u6cd5\u7ed3\u675f\uff0c\u63a7\u5236\u6743\u8fd4\u56de\u8c03\u7528\u65b9\u6cd5\u7684\u8bed\u53e5\uff0creturn\u00a0\u540e\u7684\u00a0\u4efb\u4f55\u8bed\u53e5\u90fd\u4e0d\u6267\u884c(\u5982\u679c\u00a0return\u00a0\u8bed\u53e5\u4e4b\u540e\u6709\u5176\u4ed6\u8bed\u53e5\uff0c\u7f16\u8bd1\u5668\u4f1a\u53d1\u51fa\u8b66\u544a)\u3002<\/li>\n<\/ul>\n
      \u8c03\u7528\u00a0C#\u65b9\u6cd5\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/div>\n
      \u00a0result\u00a0=\u00a0methodName\u00a0(\u00a0argumentList\u00a0)<\/div>\n
        \n
      • \u00a0methodName(\u65b9\u6cd5\u540d)\u5fc5\u987b\u4e0e\u8981\u8c03\u7528\u7684\u65b9\u6cd5\u7684\u540d\u79f0\u5b8c\u5168\u4e00\u81f4\u3002\u8bb0\u4f4f\u00a0C#\u533a\u5206\u5927\u5c0f\u5199\u3002<\/li>\n
      • \u00a0result\u00a0=\u8fd9\u4e2a\u90e8\u5206\u662f\u53ef\u9009\u7684\u3002\u5982\u6307\u5b9a\uff0cresult\u00a0\u53d8\u91cf\u5c06\u5305\u542b\u65b9\u6cd5\u8fd4\u56de\u503c\u3002\u5982\u679c\u8fd4\u56de\u7c7b\u00a0\u578b\u662f\u00a0void(\u4e0d\u8fd4\u56de\u4efb\u4f55\u503c)\uff0c\u5c31\u5fc5\u987b\u7701\u7565\u00a0result\u00a0=\u3002\u5982\u679c\u4e0d\u6307\u5b9a\u00a0result\u00a0=\u90e8\u5206\uff0c\u800c\u4e14\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u503c\uff0c\u90a3\u4e48\u65b9\u6cd5\u867d\u4f1a\u8fd0\u884c\uff0c\u4f46\u8fd4\u56de\u503c\u4f1a\u88ab\u4e22\u5f03\u3002<\/li>\n
      • \u00a0argumentList(\u5b9e\u53c2\u5217\u8868)\u63d0\u4f9b\u7531\u65b9\u6cd5\u63a5\u6536\u7684\u6570\u636e\u3002\u5fc5\u987b\u4e3a\u6bcf\u4e2a\u53c2\u6570(\u5f62\u53c2)\u63d0\u4f9b\u53c2\u6570\u00a0\u503c(\u5b9e\u53c2)\uff0c\u800c\u4e14\u6bcf\u4e2a\u5b9e\u53c2\u90fd\u5fc5\u987b\u517c\u5bb9\u4e8e\u5f62\u53c2\u7684\u7c7b\u578b\u3002\u5982\u679c\u65b9\u6cd5\u6709\u4e24\u4e2a\u6216\u66f4\u591a\u53c2\u6570\uff0c\u00a0\u90a3\u4e48\u63d0\u4f9b\u5b9e\u53c2\u65f6\u5fc5\u987b\u4ee5\u9017\u53f7\u5206\u9694\u4e0d\u540c\u5b9e\u53c2\u3002<\/li>\n<\/ul>\n
        \u00a0System.Int32\u00a0\u7c7b\u7684\u00a0Parse\u00a0\u65b9\u6cd5(System\u00a0\u662f\u547d\u540d\u7a7a\u00a0\u95f4\uff0cInt32\u00a0\u662f\u8be5\u547d\u540d\u7a7a\u95f4\u4e2d\u7684\u7c7b)\u3002\u5b83\u83b7\u53d6\u4e00\u4e2a\u00a0string\u00a0\u5e76\u628a\u5b83\u00a0\u8f6c\u6362\u6210\u00a0int<\/div>\n
        \u53d8\u91cf\u4f5c\u7528\u57df\u6216\u8303\u56f4\u662f\u6307\u8be5\u53d8\u91cf\u80fd\u8d77\u4f5c\u7528\u7684\u7a0b\u5e8f\u533a\u57df<\/div>\n
        Console.Write\u00a0\u65b9\u6cd5\u4e0e\u524d\u51e0\u4e2a\u7ec3\u4e60\u4e2d\u7684\u00a0Console.WriteLine\u00a0\u65b9\u6cd5\u5f88\u76f8\u4f3c\uff0c\u533a\u522b\u5728\u4e8e\u6700\u00a0\u540e\u4e0d\u8f93\u51fa\u6362\u884c\u7b26\u3002<\/div>\n","protected":false},"excerpt":{"rendered":"

        returnType\u00a0methodName\u00a0(\u00a0parameterList\u00a0) { \u00a0\/\/\u00a0\u8fd9\u91cc\u6dfb\u52a0\u65b9\u6cd5\u4e3b\u4f53\u8bed […]<\/p>\n","protected":false},"author":1476,"featured_media":143742,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-143741","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/143741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1476"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=143741"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/143741\/revisions"}],"predecessor-version":[{"id":143797,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/143741\/revisions\/143797"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/143742"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=143741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=143741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=143741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}