{"id":80595,"date":"2026-03-05T15:33:13","date_gmt":"2026-03-05T07:33:13","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/80595.html"},"modified":"2026-03-05T15:33:13","modified_gmt":"2026-03-05T07:33:13","slug":"c-%e5%8f%af%e5%8f%98%e5%bc%95%e7%94%a8%e7%b1%bb%e5%9e%8b%e5%92%8c%e4%b8%8d%e5%8f%af%e5%8f%98%e5%bc%95%e7%94%a8%e7%b1%bb%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/80595.html","title":{"rendered":"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b"},"content":{"rendered":"<p>\u5f15\u7528\u7c7b\u578b&#xff08;class&#xff09;\u7684\u5b9e\u4f8b\u5b58\u50a8\u5728\u6258\u7ba1\u5806\u4e0a&#xff0c;\u53d8\u91cf\u4fdd\u5b58\u7684\u662f\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u6839\u636e\u5bf9\u8c61\u521b\u5efa\u540e\u5176\u72b6\u6001\u662f\u5426\u5141\u8bb8\u88ab\u4fee\u6539&#xff0c;\u53ef\u4ee5\u5c06\u5f15\u7528\u7c7b\u578b\u5206\u4e3a\u53ef\u53d8&#xff08;Mutable&#xff09;\u548c\u4e0d\u53ef\u53d8&#xff08;Immutable&#xff09;\u4e24\u7c7b\u3002<\/p>\n<\/p>\n<h3>1. \u53ef\u53d8\u5f15\u7528\u7c7b\u578b<\/h3>\n<p>\u5b9a\u4e49&#xff1a;\u5bf9\u8c61\u521b\u5efa\u540e&#xff0c;\u5176\u5185\u90e8\u72b6\u6001&#xff08;\u5b57\u6bb5\u3001\u5c5e\u6027&#xff09;\u53ef\u4ee5\u88ab\u4fee\u6539\u3002<br \/>\n\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u53ef\u4ee5\u901a\u8fc7\u516c\u5f00\u7684 setter \u6216\u65b9\u6cd5\u66f4\u6539\u5c5e\u6027\u503c\u3002<\/p>\n<\/li>\n<li>\n<p>\u540c\u4e00\u5bf9\u8c61\u5728\u4e0d\u540c\u65f6\u95f4\u70b9\u53ef\u80fd\u5448\u73b0\u4e0d\u540c\u72b6\u6001\u3002<\/p>\n<\/li>\n<li>\n<p>\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u9700\u8981\u540c\u6b65\u673a\u5236\u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168\u3002<\/p>\n<\/li>\n<li>\n<p>\u5bb9\u6613\u4ea7\u751f\u526f\u4f5c\u7528&#xff0c;\u56e0\u4e3a\u591a\u4e2a\u5f15\u7528\u53ef\u80fd\u6307\u5411\u540c\u4e00\u5bf9\u8c61&#xff0c;\u4e00\u5904\u4fee\u6539\u4f1a\u5f71\u54cd\u6240\u6709\u5f15\u7528\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;StringBuilder\u3001List&lt;T&gt;\u3001\u81ea\u5b9a\u4e49\u7684\u5e26\u6709 setter \u7684\u7c7b\u3002<\/p>\n<\/p>\n<h3><\/h3>\n<\/p>\n<h3>2. \u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b<\/h3>\n<p>\u5b9a\u4e49&#xff1a;\u5bf9\u8c61\u4e00\u65e6\u521b\u5efa&#xff0c;\u5176\u5185\u90e8\u72b6\u6001\u5c31\u5b8c\u5168\u786e\u5b9a&#xff0c;\u4e14\u5728\u6574\u4e2a\u751f\u547d\u5468\u671f\u5185\u4e0d\u4f1a\u53d1\u751f\u4efb\u4f55\u53d8\u5316\u3002<br \/>\n\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u901a\u5e38\u6240\u6709\u5b57\u6bb5\u90fd\u662f\u53ea\u8bfb\u7684&#xff08;readonly&#xff09;&#xff0c;\u4e14\u53ea\u80fd\u5728\u6784\u9020\u51fd\u6570\u4e2d\u521d\u59cb\u5316\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u63d0\u4f9b\u4fee\u6539\u5185\u90e8\u72b6\u6001\u7684\u65b9\u6cd5&#xff08;\u65e0 setter&#xff0c;\u65e0\u6539\u53d8\u5b57\u6bb5\u7684\u65b9\u6cd5&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u201c\u4fee\u6539\u201d\u64cd\u4f5c\u4f1a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b9e\u4f8b&#xff0c;\u539f\u5b9e\u4f8b\u4fdd\u6301\u4e0d\u53d8\u3002<\/p>\n<\/li>\n<li>\n<p>\u5929\u7136\u7ebf\u7a0b\u5b89\u5168&#xff0c;\u53ef\u81ea\u7531\u5171\u4eab\u800c\u65e0\u9700\u540c\u6b65\u3002<\/p>\n<\/li>\n<li>\n<p>\u4fbf\u4e8e\u7f13\u5b58\u3001\u54c8\u5e0c\u952e\u7b49\u573a\u666f&#xff08;\u56e0\u4e3a\u72b6\u6001\u56fa\u5b9a&#xff0c;\u54c8\u5e0c\u503c\u4e0d\u53d8&#xff09;\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b&#xff1a;string&#xff08;\u5b57\u7b26\u4e32\u8fde\u63a5\u7b49\u64cd\u4f5c\u8fd4\u56de\u65b0\u5b57\u7b26\u4e32&#xff09;\u3001System.Uri\u3001System.DateTime&#xff08;\u867d\u7136\u5b83\u662f\u503c\u7c7b\u578b&#xff0c;\u4f46\u4e5f\u662f\u4e0d\u53ef\u53d8\u7684&#xff09;\u3001\u81ea\u5b9a\u4e49\u7684\u4e0d\u53ef\u53d8\u7c7b\u3002<\/p>\n<h3><\/h3>\n<\/p>\n<h3>3. \u4ee3\u7801\u793a\u4f8b<\/h3>\n<h4>3.1 \u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u793a\u4f8b<\/h4>\n<h5>\u4f7f\u7528\u00a0string<\/h5>\n<p>string s1 &#061; &#034;Hello&#034;;<br \/>\nstring s2 &#061; s1;          \/\/ s2 \u548c s1 \u5f15\u7528\u540c\u4e00\u4e2a\u5b57\u7b26\u4e32\u5bf9\u8c61<br \/>\nConsole.WriteLine($&#034;s1: {s1}, s2: {s2}&#034;); \/\/ \u8f93\u51fa&#xff1a;Hello, Hello<\/p>\n<p>\/\/ \u5c1d\u8bd5\u201c\u4fee\u6539\u201ds1 \u2014\u2014 \u5b9e\u9645\u4e0a\u662f\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u5b57\u7b26\u4e32\u5bf9\u8c61<br \/>\ns1 &#061; s1 &#043; &#034; World&#034;;<br \/>\nConsole.WriteLine($&#034;s1: {s1}, s2: {s2}&#034;);<br \/>\n\/\/ \u8f93\u51fa&#xff1a;s1: Hello World, s2: Hello   (s2 \u4ecd\u7136\u6307\u5411\u539f\u5b57\u7b26\u4e32)<\/p>\n<\/p>\n<h5>\u81ea\u5b9a\u4e49\u4e0d\u53ef\u53d8\u7c7b\u00a0ImmutablePerson<\/h5>\n<p>public class ImmutablePerson<br \/>\n{<br \/>\n    public string Name { get; }<br \/>\n    public int Age { get; }<\/p>\n<p>    public ImmutablePerson(string name, int age)<br \/>\n    {<br \/>\n        Name &#061; name;<br \/>\n        Age &#061; age;<br \/>\n    }<\/p>\n<p>    \/\/ \u201c\u4fee\u6539\u201d\u5e74\u9f84&#xff1a;\u8fd4\u56de\u4e00\u4e2a\u65b0\u5bf9\u8c61<br \/>\n    public ImmutablePerson WithAge(int newAge)<br \/>\n    {<br \/>\n        return new ImmutablePerson(this.Name, newAge);<br \/>\n    }<\/p>\n<p>    public override string ToString() &#061;&gt; $&#034;{Name} ({Age})&#034;;<br \/>\n}<\/p>\n<p>\/\/ \u4f7f\u7528<br \/>\nvar p1 &#061; new ImmutablePerson(&#034;Alice&#034;, 30);<br \/>\nvar p2 &#061; p1.WithAge(31);    \/\/ p1 \u4fdd\u6301\u4e0d\u53d8&#xff0c;p2 \u662f\u65b0\u5bf9\u8c61<br \/>\nConsole.WriteLine(p1);       \/\/ Alice (30)<br \/>\nConsole.WriteLine(p2);       \/\/ Alice (31)<\/p>\n<\/p>\n<h4>3.2 \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u793a\u4f8b<\/h4>\n<h5>\u4f7f\u7528\u00a0StringBuilder<\/h5>\n<p>StringBuilder sb1 &#061; new StringBuilder(&#034;Hello&#034;);<br \/>\nStringBuilder sb2 &#061; sb1;          \/\/ sb2 \u548c sb1 \u5f15\u7528\u540c\u4e00\u4e2a\u5bf9\u8c61<\/p>\n<p>Console.WriteLine(sb1); \/\/ Hello<br \/>\nConsole.WriteLine(sb2); \/\/ Hello<\/p>\n<p>\/\/ \u4fee\u6539 sb1<br \/>\nsb1.Append(&#034; World&#034;);<\/p>\n<p>\/\/ sb2 \u4e5f\u53d7\u5230\u5f71\u54cd&#xff0c;\u56e0\u4e3a\u5b83\u4eec\u6307\u5411\u540c\u4e00\u5bf9\u8c61<br \/>\nConsole.WriteLine(sb1); \/\/ Hello World<br \/>\nConsole.WriteLine(sb2); \/\/ Hello World<\/p>\n<h5>\u81ea\u5b9a\u4e49\u53ef\u53d8\u7c7b\u00a0MutablePerson<\/h5>\n<p>public class MutablePerson<br \/>\n{<br \/>\n    public string Name { get; set; }<br \/>\n    public int Age { get; set; }<\/p>\n<p>    public override string ToString() &#061;&gt; $&#034;{Name} ({Age})&#034;;<br \/>\n}<\/p>\n<p>\/\/ \u4f7f\u7528<br \/>\nvar p1 &#061; new MutablePerson { Name &#061; &#034;Bob&#034;, Age &#061; 25 };<br \/>\nvar p2 &#061; p1;      \/\/ p2 \u5f15\u7528\u540c\u4e00\u4e2a\u5bf9\u8c61<\/p>\n<p>p1.Age &#061; 26;      \/\/ \u4fee\u6539 p1<br \/>\nConsole.WriteLine(p1); \/\/ Bob (26)<br \/>\nConsole.WriteLine(p2); \/\/ Bob (26)   \u2014\u2014 p2 \u4e5f\u53d8\u4e86<\/p>\n<\/p>\n<h3>4. \u603b\u7ed3\u5bf9\u6bd4<\/h3>\n<table>\n<tr>\u7279\u6027\u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b<\/tr>\n<tbody>\n<tr>\n<td>\u72b6\u6001\u4fee\u6539<\/td>\n<td>\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539\u5bf9\u8c61\u5185\u5bb9<\/td>\n<td>\u4fee\u6539\u64cd\u4f5c\u8fd4\u56de\u65b0\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>\u7ebf\u7a0b\u5b89\u5168<\/td>\n<td>\u901a\u5e38\u4e0d\u5b89\u5168&#xff0c;\u9700\u540c\u6b65<\/td>\n<td>\u5929\u7136\u5b89\u5168&#xff0c;\u53ef\u81ea\u7531\u5171\u4eab<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\/\u6027\u80fd<\/td>\n<td>\u4fee\u6539\u539f\u5730\u8fdb\u884c&#xff0c;\u65e0\u9700\u989d\u5916\u5206\u914d<\/td>\n<td>\u6bcf\u6b21\u4fee\u6539\u53ef\u80fd\u5206\u914d\u65b0\u5bf9\u8c61<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u9700\u8981\u9891\u7e41\u4fee\u6539\u72b6\u6001\u7684\u573a\u666f<\/td>\n<td>\u9700\u8981\u5171\u4eab\u3001\u7f13\u5b58\u3001\u54c8\u5e0c\u952e\u7684\u573a\u666f<\/td>\n<\/tr>\n<tr>\n<td>\u5e38\u89c1\u4f8b\u5b50<\/td>\n<td>StringBuilder,\u00a0List&lt;T&gt;<\/td>\n<td>string,\u00a0System.Uri<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u7528\u7c7b\u578b&#xff08;class&#xff09;\u7684\u5b9e\u4f8b\u5b58\u50a8\u5728\u6258\u7ba1\u5806\u4e0a&#xff0c;\u53d8\u91cf\u4fdd\u5b58\u7684\u662f\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u6839\u636e\u5bf9\u8c61\u521b\u5efa\u540e\u5176\u72b6\u6001\u662f\u5426\u5141\u8bb8\u88ab\u4fee\u6539&#xff0c;\u53ef\u4ee5\u5c06\u5f15\u7528\u7c7b\u578b\u5206\u4e3a\u53ef\u53d8&#xff08;Mutable&#xff09;\u548c\u4e0d\u53ef\u53d8&#xff08;Immutable&#xff09;\u4e24\u7c7b\u30021. \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u5b9a\u4e49&#xff1a;\u5bf9\u8c61\u521b\u5efa\u540e&#xff0c;\u5176\u5185\u90e8\u72b6\u6001&#xff08;\u5b57\u6bb5\u3001\u5c5e\u6027&#xff09;\u53ef\u4ee5\u88ab\u4fee\u6539\u3002<br \/>\n\u7279\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u516c\u5f00\u7684 setter \u6216\u65b9\u6cd5\u66f4<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,190],"topic":[],"class_list":["post-80595","post","type-post","status-publish","format-standard","hentry","category-server","tag-c","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/80595.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5f15\u7528\u7c7b\u578b&#xff08;class&#xff09;\u7684\u5b9e\u4f8b\u5b58\u50a8\u5728\u6258\u7ba1\u5806\u4e0a&#xff0c;\u53d8\u91cf\u4fdd\u5b58\u7684\u662f\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u6839\u636e\u5bf9\u8c61\u521b\u5efa\u540e\u5176\u72b6\u6001\u662f\u5426\u5141\u8bb8\u88ab\u4fee\u6539&#xff0c;\u53ef\u4ee5\u5c06\u5f15\u7528\u7c7b\u578b\u5206\u4e3a\u53ef\u53d8&#xff08;Mutable&#xff09;\u548c\u4e0d\u53ef\u53d8&#xff08;Immutable&#xff09;\u4e24\u7c7b\u30021. \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u5b9a\u4e49&#xff1a;\u5bf9\u8c61\u521b\u5efa\u540e&#xff0c;\u5176\u5185\u90e8\u72b6\u6001&#xff08;\u5b57\u6bb5\u3001\u5c5e\u6027&#xff09;\u53ef\u4ee5\u88ab\u4fee\u6539\u3002 \u7279\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u516c\u5f00\u7684 setter \u6216\u65b9\u6cd5\u66f4\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/80595.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-05T07:33:13+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/80595.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/80595.html\",\"name\":\"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-03-05T07:33:13+00:00\",\"dateModified\":\"2026-03-05T07:33:13+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/80595.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/80595.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/80595.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/80595.html","og_locale":"zh_CN","og_type":"article","og_title":"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5f15\u7528\u7c7b\u578b&#xff08;class&#xff09;\u7684\u5b9e\u4f8b\u5b58\u50a8\u5728\u6258\u7ba1\u5806\u4e0a&#xff0c;\u53d8\u91cf\u4fdd\u5b58\u7684\u662f\u5bf9\u8c61\u7684\u5f15\u7528\u3002\u6839\u636e\u5bf9\u8c61\u521b\u5efa\u540e\u5176\u72b6\u6001\u662f\u5426\u5141\u8bb8\u88ab\u4fee\u6539&#xff0c;\u53ef\u4ee5\u5c06\u5f15\u7528\u7c7b\u578b\u5206\u4e3a\u53ef\u53d8&#xff08;Mutable&#xff09;\u548c\u4e0d\u53ef\u53d8&#xff08;Immutable&#xff09;\u4e24\u7c7b\u30021. \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u5b9a\u4e49&#xff1a;\u5bf9\u8c61\u521b\u5efa\u540e&#xff0c;\u5176\u5185\u90e8\u72b6\u6001&#xff08;\u5b57\u6bb5\u3001\u5c5e\u6027&#xff09;\u53ef\u4ee5\u88ab\u4fee\u6539\u3002 \u7279\u70b9&#xff1a;\u53ef\u4ee5\u901a\u8fc7\u516c\u5f00\u7684 setter \u6216\u65b9\u6cd5\u66f4","og_url":"https:\/\/www.wsisp.com\/helps\/80595.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-03-05T07:33:13+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/80595.html","url":"https:\/\/www.wsisp.com\/helps\/80595.html","name":"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-03-05T07:33:13+00:00","dateModified":"2026-03-05T07:33:13+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/80595.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/80595.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/80595.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C# \u53ef\u53d8\u5f15\u7528\u7c7b\u578b\u548c\u4e0d\u53ef\u53d8\u5f15\u7528\u7c7b\u578b"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/80595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=80595"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/80595\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=80595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=80595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=80595"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=80595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}