{"id":135594,"date":"2019-02-26T11:06:55","date_gmt":"2019-02-26T03:06:55","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=135594"},"modified":"2019-01-31T09:08:03","modified_gmt":"2019-01-31T01:08:03","slug":"netcore-3-preview2","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/netcore-3-preview2.html","title":{"rendered":".NET Core 3 Preview 2 \u53d1\u5e03\uff0c\u6b63\u5f0f\u7248\u4e0d\u8fdc\u4e86"},"content":{"rendered":"
.NET Core 3 Preview 2 \u53d1\u5e03\u4e86\uff0c\u6b64\u7248\u672c\u4e3b\u8981\u5e26\u6765\u4e86 C# 8 \u76f8\u5173\u7684\u65b0\u529f\u80fd\uff0cC# 8 Preview 2 \u662f .NET Core 3 SDK \u7684\u4e00\u90e8\u5206\u3002<\/p>\n
<\/p>\n
C# 8 \u4e2d\u4f7f\u7528\u6a21\u5f0f\u8fdb\u884c\u66f4\u591a\u64cd\u4f5c\uff0c\u4e3b\u8981\u7279\u6027\u5305\u62ec\uff1a<\/p>\n
\u6539\u53d8\u9700\u8981\u7f29\u8fdb\u4ee3\u7801\u7684\u65b9\u5f0f\uff0c\u73b0\u5728\u53ef\u4ee5\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\uff0c\u8be5\u4ee3\u7801\u5c06 using \u58f0\u660e\u9644\u52a0\u5230\u5f53\u524d\u8bed\u53e5\u5757\u7684\u8303\u56f4\uff0c\u7136\u540e\u5c06\u8be5\u5bf9\u8c61\u653e\u5728\u5176\u672b\u5c3e\u3002<\/p>\n
[cc]static void Main(string[] args)
\n{
\nusing var options = Parse(args);
\nif (options[\"verbose\"]) { WriteLine(\"Logging...\"); }<\/p>\n
} \/\/ options disposed here[\/cc]<\/p>\n
C# 8 \u5f15\u5165\u4e86 switch \u8868\u8fbe\u5f0f\uff0c\u5b83\u652f\u6301\u66f4\u7b80\u6d01\u7684\u8bed\u6cd5\uff0c\u56e0\u4e3a\u5b83\u662f\u4e00\u4e2a\u8868\u8fbe\u5f0f\uff0c\u6240\u4ee5\u4f1a\u8fd4\u56de\u4e00\u4e2a\u503c\uff0c\u5e76\u5b8c\u5168\u96c6\u6210\u5728\u6a21\u5f0f\u5339\u914d\u4e2d\u3002<\/p>\n
switch \u5173\u952e\u5b57\u662f \u201cinfix\u201d\uff0c\u7528\u6cd5 demo\uff1a<\/p>\n
[cc]static string Display(object o) => o switch
\n{
\nPoint { X: 0, Y: 0 } => \"origin\",
\nPoint { X: var x, Y: var y } => $\"({x}, {y})\",
\n_ => \"unknown\"
\n};[\/cc]
\n\u6216\u8005\uff1a<\/p>\n
[cc]static State ChangeState(State current, Transition transition, bool hasKey) =>
\n(current, transition) switch
\n{
\n(Opened, Close) => Closed,
\n(Closed, Open) => Opened,
\n(Closed, Lock) when hasKey => Locked,
\n(Locked, Unlock) when hasKey => Closed,
\n_ => throw new InvalidOperationException($\"Invalid transition\")
\n};[\/cc]<\/p>\n
\u5f02\u6b65\u6d41\u662f C# 8 \u7684\u53e6\u4e00\u4e2a\u4e3b\u8981\u6539\u8fdb\uff0c\u5b83\u9700\u8981\u7f16\u8bd1\u5668\u548c\u6846\u67b6\u5e93\u5339\u914d\u624d\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\u5982\u679c\u8981\u4f7f\u7528 Visual Studio 2019 Preview 2 \u6216 Visual Studio Code \u7684 C# \u6269\u5c55\u7684\u6700\u65b0\u9884\u89c8\u7248\u8fdb\u884c\u5f00\u53d1\uff0c\u5219\u9700\u8981 .NET Core 3.0 Preview 2 \u624d\u80fd\u4f7f\u7528\u5f02\u6b65\u6d41\u3002<\/p>\n
\u9664\u4e86 C# 8 \u76f8\u5173\u53d8\u5316\uff0c\u8fd8\u5305\u62ec\u4ee5\u4e0b\u66f4\u65b0\u5185\u5bb9\uff1a<\/p>\n
.NET Core 3 Preview 2 \u53d1\u5e03\u4e86\uff0c\u6b64\u7248\u672c\u4e3b\u8981\u5e26\u6765\u4e86 C# 8 \u76f8\u5173\u7684\u65b0\u529f\u80fd\uff0cC# 8 Pre […]<\/p>\n","protected":false},"author":63,"featured_media":121417,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-135594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135594","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=135594"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135594\/revisions"}],"predecessor-version":[{"id":135599,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/135594\/revisions\/135599"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/121417"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=135594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=135594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=135594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}