{"id":10006762,"date":"2022-10-30T11:49:12","date_gmt":"2022-10-30T03:49:12","guid":{"rendered":"https:\/\/ityet.com\/?p=10006762"},"modified":"2022-10-30T11:49:12","modified_gmt":"2022-10-30T03:49:12","slug":"c%e9%9a%90%e8%97%8f%e5%9f%ba%e7%b1%bb%e6%88%90%e5%91%98-base%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006762","title":{"rendered":"C#\u9690\u85cf\u57fa\u7c7b\u6210\u5458\/base\u7528\u6cd5"},"content":{"rendered":"<h2>\u4ee3\u7801\u5982\u4e0b\uff1a<\/h2>\n<p>class Program<\/p>\n<pre><code>{\n    public class Student\/\/\u5b9a\u4e49\u4e00\u4e2a\u5b66\u751f\u7c7b\uff0c\u5176\u4e2d\u5b57\u6bb5\u6709\u59d3\u540d\u3001\u5e74\u9f84\u3001\u5b66\u53f7\n    {\n        private string Name;\n        private string Age;\n        private int Id;\n        public Student(string name,string age,int id)\/\/\u521b\u5efa\u5b66\u751f\u7c7b\u7684\u6784\u9020\u51fd\u6570\n        {\n            Name = name;\n            Age = age;\n            Id = id;\n        }\n        public void sc()\/\/\u5b9a\u4e49\u4e00\u4e2a\u8f93\u51fa\u65b9\u6cd5sc,\u5206\u522b\u8f93\u51fa\u59d3\u540d\uff0c\u5e74\u9f84\uff0c\u5b66\u53f7\u4fe1\u606f\n        {\n            Console.WriteLine(&quot;\u59d3\u540d\uff1a{0}&quot;, Name);\n            Console.WriteLine(&quot;\u5e74\u9f84\uff1a{0}&quot;, Age);\n            Console.WriteLine(&quot;\u5b66\u53f7\uff1a{0}&quot;, Id);\n        }\n    }\n    public class e : Student\/\/\u5b9a\u4e49\u4e00\u4e2a\u65b0\u7c7be\u6765\u57fa\u7840\u5b66\u751f\u7c7b\uff0c\u6362\u4e2a\u8bf4\u6cd5\u5c31\u662fe\u662f\u5b66\u751f\u7c7b\u7684\u5b50\u7c7b\n    {\n        private string department;\/\/\u5b9a\u4e49\u4e24\u4e2a\u5b57\u6bb5\u4e13\u4e1a\u548c\u6027\u522b\n        private string sex;\n        public e(string name, string age, int id, string d,string s)\n            : base(name, age, id)\n        {\n            department = d;\n            sex = s;\n        }\n        new public void sc()\/\/\u4f7f\u7528new\u4fee\u9970\u7b26\u6e05\u6670\u7684\u8868\u660e\u4e86\u6d3e\u751f\u7c7b\u9690\u85cf\u4e86\u57fa\u7c7b\uff0c\u5982\u679c\u4e0d\u52a0new\uff0c\u7f16\u8bd1\u4f1a\u6709\u8b66\u544a\n        {\n            base.sc();\/\/\u8c03\u7528\u57fa\u7c7b\u7684\u6784\u9020\u51fd\u6570\n            Console.WriteLine(&quot;\u4e13\u4e1a\uff1a{0}&quot;, department);\n            Console.WriteLine(&quot;\u6027\u522b\uff1a{0}&quot;, sex);\n        }\n    }\n    static void Main(string[] args)\n    {\n        e s1 = new e(&quot;\u5f20\u4e09&quot;, &quot;22&quot;, 12, &quot;\u8f6f\u4ef6\u5de5\u7a0b&quot;, &quot;\u7537&quot;);\/\/\u5b9e\u4f8b\u5316\u6d3e\u751f\u7c7b\u5bf9\u8c61\u4e3as1\uff0c\u5199\u5165\u76f8\u5e94\u4fe1\u606f\u3002\n        s1.sc();\n    }\n}\n<\/code><\/pre>\n<h2>\u7f16\u8bd1\u7ed3\u679c\u5982\u4e0b\uff1a<\/h2>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc3nge\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h4>base \u662f\u6307\u57fa\u7c7b\u7684\u5bf9\u8c61,\u5176\u7279\u70b9\u5982\u4e0b\u3002<\/h4>\n<p>(1)\u4f7f\u7528 base \u5173\u952e\u5b57\u53ef\u8bbf\u95ee\u57fa\u7c7b\u7684\u5b57\u6bb5\u548c\u65b9\u6cd5\u3002<br \/>(2)\u4f7f\u7528 base \u5173\u952e\u5b57\u53ef\u8c03\u7528\u57fa\u7c7b\u7684\u6784\u9020\u51fd\u6570\u3002\u6d3e\u751f\u7c7b\u7ee7\u627f\u57fa\u7c7b\u4e2d\u9664\u4e86\u6784\u9020\u51fd\u6570,\u6790\u6784\u51fd\u6570\u4e4b\u5916\u7684\u6240\u6709\u6210\u5458,\u4f46\u662f,\u6d3e\u751f\u7c7b\u4ecd\u7136\u53ef\u4ee5\u8c03\u7528\u76f4\u63a5\u57fa\u7c7b\u7684\u6784\u9020\u51fd\u6570\u3002<br \/>(3)base \u4e0d\u80fd\u5305\u542b\u5728\u9759\u6001\u65b9\u6cd5\u548c\u9759\u6001\u6784\u9020\u51fd\u6570\u4e2d,\u4e5f\u4e0d\u80fd\u901a\u8fc7 base \u8bbf\u95ee\u5176\u4ed6\u9759\u6001<br \/>(4)\u53ea\u80fd\u5728\u6d3e\u751f\u7c7b\u5185\u4f7f\u7528 base \u8bbf\u95ee\u57fa\u7c7b\u88ab\u9690\u85cf\u7684\u6210\u5458\u3002\u5728\u6d3e\u751f\u7c7b\u4e4b\u5916,\u4e0d\u80fd\u901a\u8fc7\u6d3e\u751f\u7c7b\u7684\u5bf9\u8c61\u8bbf\u95ee\u88ab\u9690\u85cf\u7684\u6210\u5458\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042711068\">https:\/\/segmentfault.com\/a\/1190000042711068<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee3\u7801\u5982\u4e0b\uff1a class Program { public class Student\/\/\u5b9a\u4e49\u4e00\u4e2a\u5b66\u751f\u7c7b\uff0c\u5176\u4e2d\u5b57 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10006762","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006762","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006762"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006762\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}