{"id":1162,"date":"2014-05-09T07:52:12","date_gmt":"2014-05-09T07:52:12","guid":{"rendered":"http:\/\/www.clonefactor.com\/wordpress\/?p=1162"},"modified":"2014-05-09T07:52:37","modified_gmt":"2014-05-09T07:52:37","slug":"unity3d-func","status":"publish","type":"post","link":"https:\/\/www.clonefactor.com\/wordpress\/program\/unity3d\/1162\/","title":{"rendered":"unity3d Func<>"},"content":{"rendered":"<pre class=\"brush:csharp\">public enum ROAD{\r\n\tEAST,\r\n\tWEST,\r\n\tSOUTH,\r\n\tNORTH\r\n}\r\nstring EastWay(int _len){return (\"East : \"+ _len);}\r\nstring WestWay(int _len){return (\"West : \"+ _len);}\r\nstring SouthWay(int _len){return (\"South : \"+ _len);}\r\nstring NorthWay(int _len){return (\"North : \"+ _len);}\r\nprivate Func&lt;int, string&gt; WhichWay(ROAD _way)\r\n{\r\n\tswitch( _way )\r\n\t{\r\n\tdefault:\r\n\tcase ROAD.EAST: return EastWay;\r\n\tcase ROAD.WEST: return WestWay;\r\n\tcase ROAD.SOUTH: return SouthWay;\r\n\tcase ROAD.NORTH: return NorthWay;\r\n\t}\r\n}\r\n\r\nvoid Main()\r\n{\r\n\tDebug.Log (WhichWay(ROAD.SOUTH)(10));\t\/\/ South : 10\r\n}<\/pre>\n<p>It&#8217;s working !!!<\/p>\n<p>\u7528\u4e00\u500b\u7a0b\u5e8f\u53bb\u6c7a\u5b9a\u4f60\u4f7f\u7528\u5176\u4ed6\u7a0b\u5e8f\u7684\u65b9\u5f0f.<\/p>\n<p>\u7c21\u55ae\u8aaa, \u904b\u4f5c\u6642 WhichWay(ROAD.SOUTH) \u56e0\u70ba Func retrun \u7684\u95dc\u4fc2\u6703 return SouthWay \u9019\u4e00\u500b class,<br \/>\n\u7136\u5f8c WhichWay(ROAD.SOUTH)(10) \u5247\u6703\u5316\u70ba SouthWay(10) \u7136\u5f8c\u518d return \u70ba &#8220;South : 10&#8221; \u9019\u4e00\u500b string.<\/p>\n<p>\u5927\u91cf\u7684 stage \u5224\u65b7\u6642\u975e\u5e38\u6709\u7528.<\/p>\n<p>\u9700\u6ce8\u610f\u7684\u662f Func&lt;\u7b2c\u4e00\u53c3\u6578, \u7b2c\u4e8c\u53c3\u6578&gt;<br \/>\n\u7b2c\u4e00\u53c3\u6578\u662f input. \u7b2c\u4e8c\u53c3\u6578\u662f\u88e1\u982d\u7684 class \u7684 return type.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>public enum ROAD{ EAST, WEST, SOUTH, NORTH } strin &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[43],"class_list":["post-1162","post","type-post","status-publish","format-standard","hentry","category-unity3d","tag-unity3d-2"],"_links":{"self":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1162"}],"version-history":[{"count":0,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/posts\/1162\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clonefactor.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}