{"id":785,"date":"2023-11-27T13:09:01","date_gmt":"2023-11-27T04:09:01","guid":{"rendered":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=785"},"modified":"2023-11-27T13:09:01","modified_gmt":"2023-11-27T04:09:01","slug":"c12%e3%81%ae%e6%96%b0%e6%a9%9f%e8%83%bd%e4%b8%80%e9%83%a8%e6%8a%9c%e7%b2%8b","status":"publish","type":"post","link":"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=785","title":{"rendered":"C#12\u306e\u65b0\u6a5f\u80fd(\u4e00\u90e8\u629c\u7c8b)"},"content":{"rendered":"\n<p>.NET8\u3067\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u308b\u3001C#12\u306e\u65b0\u6a5f\u80fd\u3092\u8abf\u3079\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>\u2460\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5f0f<br>\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5f0f\u306f\u914d\u5217\u3084List\u7b49\u306e\u521d\u671f\u5316\u3084\u4ee3\u5165\u306a\u3069\u306b\u4f7f\u7528\u3067\u304d\u308b\u3002<br>\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5f0f\" data-lang=\"C#\"><code>int[] iary_old = new int[] { 1, 2, 3, 4 };\t\/\/ \u5f93\u6765\nint[] iary_new = [ 1, 2, 3, 4 ];\t\/\/ C#12\u4ee5\u964d\n\nList&lt;string&gt; slst_old = new List&lt;string&gt;() { &quot;Hello&quot; , &quot;World&quot; };\t\/\/ \u5f93\u6765\nList&lt;string&gt; slst_new = [ &quot;Hello&quot; , &quot;World&quot; ];\t\/\/ C#12\u4ee5\u964d<\/code><\/pre><\/div>\n\n\n\n<p>new\u3068\u521d\u671f\u5316\u3092\u4e00\u7dd2\u306b\u884c\u3046\u30b7\u30f3\u30bf\u30c3\u30af\u30b9\u30b7\u30e5\u30ac\u30fc\u3060\u306d\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u30b9\u30d7\u30ec\u30c3\u30c9\u6f14\u7b97\u5b50&#8221;..&#8221;\u3068\u3044\u3046\u3082\u306e\u304c\u4f7f\u7528\u3067\u304d\u308b\u3002\u3053\u308c\u3092\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u524d\u306b\u3064\u3051\u308b\u3068\u3001\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8981\u7d20\u306b\u7f6e\u304d\u63db\u308f\u308b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"..\u6f14\u7b97\u5b50\" data-lang=\"C#\"><code>&gt; int[] a = [1,2,3];\n&gt; int[] b = [4,5,6];\n&gt; int[] c = [..a,..b];\n&gt; c\nint[6] { 1, 2, 3, 4, 5, 6 }<\/code><\/pre><\/div>\n\n\n\n<p>\u2461\u30e9\u30e0\u30c0\u5f0f\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024<br>\u30e9\u30e0\u30c0\u5f0f\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30e9\u30e0\u30c0\u5f0f\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\" data-lang=\"C#\"><code>var PlusN = ( int Value, int Addition=1 ) =&gt; Value + Addition;\n\nConsole.WriteLine($&quot;PlusN(10)={PlusN(10)}&quot;);\nConsole.WriteLine($&quot;PlusN(10,2)={PlusN(10,2)}&quot;);\n\/*\t\u7d50\u679c\n\tPlusN(10)=11\n\tPlusN(10,2)=12\n *\/\n\/\/ NG\u30d1\u30bf\u30fc\u30f3\nFunc&lt;int,int,int&gt; PlusN = ( Value, Addition=1 ) =&gt; Value + Addition;\n\/\/ error CS9098: \u6697\u9ed9\u7684\u306b\u578b\u6307\u5b9a\u3055\u308c\u305f\u30e9\u30e0\u30c0\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc &#39;Addition&#39; \u306b\u65e2\u5b9a\u5024\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\nFunc&lt;int,int,int&gt; PlusN = ( int Value, int Addition=1 ) =&gt; Value + Addition;\n\/\/ warning CS9099: \u30d1\u30e9\u30e1\u30fc\u30bf\u30fc 2 \u306e\u30e9\u30e0\u30c0\u3067\u306e\u65e2\u5b9a\u5024\u306f &#39;1&#39; \u3060\u304c\u3001\u30bf\u30fc\u30b2\u30c3\u30c8\u30c7\u30ea\u30b2\u30fc\u30c8\u578b\u3067\u306f &#39;&lt;missing&gt;&#39; \u3067\u3059\u3002<\/code><\/pre><\/div>\n\n\n\n<p>\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u578b\u3092\u660e\u793a\u7684\u306b\u6307\u5b9a\u3057\u306a\u3044\u3068\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u306e\u8a2d\u5b9a\u306f\u51fa\u6765\u306a\u3044\u3088\u3046\u3060\u3002<br>\u307e\u305f\u3001\u578b\u3068\u3057\u3066\u5f15\u6570\u306e\u6570\u3092\u6307\u5b9a\u3057\u3066\u3057\u307e\u3046\u3068\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u8b66\u544a\u304c\u51fa\u3066\u3001\u5b9f\u884c\u6642\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068\u3001\u5b9f\u884c\u6642\u30a8\u30e9\u30fc<br>CS7036: &#8216;arg2&#8217; \u306e\u5fc5\u8981\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc &#8216;Func&#8217; \u306b\u5bfe\u5fdc\u3059\u308b\u7279\u5b9a\u306e\u5f15\u6570\u304c\u3042\u308a\u307e\u305b\u3093<br>\u3068\u306a\u3063\u3066\u3057\u307e\u3046\u3002<\/p>\n\n\n\n<p>\u2462\u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf<br>record\u578b\u3067\u306f\u4ee5\u524d\u304b\u3089\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u305f\u304c\u3001class\u3084struct\u3067\u3082\u4f7f\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-csharp\" data-file=\"\u30d7\u30e9\u30a4\u30de\u30ea\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\" data-lang=\"C#\"><code>public class Person(string Name, string Mail, DateTime Birthday) {\n\tpublic string Name { get; } = Name;\n\tpublic string Mail { get; } = Mail;\n\tpublic DateTime Birthday { get; } = Birthday;\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u4ed6\u306b\u3082\u3044\u304f\u3064\u304b\u65b0\u6a5f\u80fd\u304c\u3042\u308b\u306e\u3060\u304c\u3001\u3059\u3050\u306b\u4f7f\u3048\u305d\u3046\u306a\u306e\u306f\u3053\u308c\u3050\u3089\u3044\u304b\u306a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>.NET8\u3067\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u308b\u3001C#12\u306e\u65b0\u6a5f\u80fd\u3092\u8abf\u3079\u3066\u307f\u305f\u3002 \u2460\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u5f0f\u30b3\u30ec &hellip; <a href=\"https:\/\/sumomo.ohwaki.jp\/wordpress\/?p=785\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,9,4],"tags":[],"class_list":["post-785","post","type-post","status-publish","format-standard","hentry","category-net","category-c","category-4"],"_links":{"self":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=785"}],"version-history":[{"count":3,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/785\/revisions"}],"predecessor-version":[{"id":788,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/785\/revisions\/788"}],"wp:attachment":[{"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sumomo.ohwaki.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}