{"id":1481,"date":"2025-03-09T01:24:37","date_gmt":"2025-03-08T17:24:37","guid":{"rendered":"http:\/\/codermr.com\/?p=1481"},"modified":"2025-03-09T01:24:39","modified_gmt":"2025-03-08T17:24:39","slug":"c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81","status":"publish","type":"post","link":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/","title":{"rendered":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">C#\u00a0Inheritance<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Inheritance (Derived and Base Class) \u6d3e\u751f\u7c7b\u548c\u57fa\u7c7b<\/h2>\n\n\n\n<p>In C#, it is possible to <strong>inherit<\/strong> fields and methods from one class to another. We group the &#8220;inheritance concept&#8221; into two categories:<\/p>\n\n\n\n<ul>\n<li><strong>Derived Class<\/strong>\u00a0(child) &#8211; the class that <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">inherits from another class<\/mark><\/li>\n\n\n\n<li><strong>Base Class<\/strong>\u00a0(parent) &#8211; the class <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">being inherited from<\/mark><\/li>\n<\/ul>\n\n\n\n<p>To inherit from a class, use the\u00a0<code>:<\/code>\u00a0symbol  <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u3010C# \u4e2d\u7ee7\u627f\u4f7f\u7528\u5f15\u53f7 : \u3011<\/mark><\/strong><\/p>\n\n\n\n<p>In the example below, the\u00a0<code>Car<\/code>\u00a0class (child) <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">inherits<\/mark><\/strong> the fields and methods <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">from<\/mark><\/strong> the\u00a0<code>Vehicle<\/code>\u00a0class (parent):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Vehicle  \/\/ base class (parent) \n{\n  public string brand = \"Ford\";  \/\/ Vehicle field\n  public void honk()             \/\/ Vehicle method \n  {                    \n    Console.WriteLine(\"Tuut, tuut!\");\n  }\n}\n\nclass Car : Vehicle  \/\/ <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">derived class (child)  \u6d3e\u751f\u7c7b<\/mark><\/strong>\n{\n  public string modelName = \"Mustang\";  \/\/ Car field\n}\n\nclass Program\n{\n  static void Main(string&#91;] args)\n  {\n    \/\/ Create a myCar object\n    Car myCar = new Car();\n\n    \/\/ Call the honk() method (From the Vehicle class) on the myCar object\n    myCar.honk(); <strong>\/\/\u2588\u8c03\u7528\u7236\u7c7b\u4e2d\u7684\u65b9\u6cd5<\/strong>\n\n    \/\/ Display the value of the brand field (from the Vehicle class) and the value of the modelName from the Car class\n    Console.WriteLine(myCar.brand + \" \" + myCar.modelName);\n  }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Why And When To Use &#8220;Inheritance&#8221;?<\/h4>\n\n\n\n<p>&#8211; It is useful for code reusability: reuse fields and methods of an existing class when you create a new class.<\/p>\n\n\n\n<p><strong>Tip:<\/strong>&nbsp;Also take a look at the next chapter,&nbsp;<a href=\"https:\/\/www.w3schools.com\/cs\/cs_polymorphism.php\">Polymorphism<\/a>, which uses inherited methods to perform different tasks.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The sealed Keyword  <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u2588 sealed \u5173\u952e\u5b57<\/mark><\/h2>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u5982\u679c\u4f60\u4e0d\u60f3\u8ba9\u522b\u7684\u7c7b\u7ee7\u627f Vehicle \u7c7b\uff0c\u5219\u53ef\u4ee5\u7528 sealed \u5173\u952e\u5b57\u4fee\u9970 Vehicle \u7c7b\u3002<\/mark><\/strong><\/p>\n\n\n\n<p>If you don&#8217;t want other classes to inherit from a class, use the\u00a0<code>sealed<\/code>\u00a0keyword:<\/p>\n\n\n\n<p>If you try to access a\u00a0<code>sealed<\/code>\u00a0class, C# will generate an error:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sealed class Vehicle \n{\n  ...\n}\n\nclass Car : Vehicle \n{\n  ...\n}<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">C#\u00a0Polymorphism \u3010<a href=\"cmd:\/\/Speak\/_us_\/polymorphism\">\/\u02ccp\u0251l\u026a&#8217;m\u0254rf\u026azm\/<\/a>\u3011\u3001virtual\u3001override<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Polymorphism and Overriding Methods<\/h2>\n\n\n\n<p>Polymorphism means &#8220;many forms&#8221;, and it occurs <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">when we have many classes that are related to each other by inheritance.<\/mark><\/strong><\/p>\n\n\n\n<p>Like we specified in the previous chapter;\u00a0<a href=\"https:\/\/www.w3schools.com\/cs\/cs_inheritance.php\"><strong>Inheritance<\/strong><\/a>\u00a0lets us inherit fields and methods from another class.\u00a0<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><strong>Polymorphism<\/strong>\u00a0uses those methods to perform different tasks. This allows us to perform a single action in different ways.<\/mark><\/p>\n\n\n\n<p>For example, think of a base class called\u00a0<code>Animal<\/code>\u00a0that has a method called\u00a0<code>animalSound()<\/code>. <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">Derived classes<\/mark><\/strong> of Animals could be Pigs, Cats, Dogs, Birds &#8211; And they also have their own implementation of an animal sound (the pig oinks, and the cat meows, etc.):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal  \/\/ Base class (parent) \n{\n  public void animalSound() \n  {\n    Console.WriteLine(\"The animal makes a sound\");\n  }\n}\n\nclass Pig : Animal  \/\/ Derived class (child) \n{\n  public void animalSound() \n  {\n    Console.WriteLine(\"The pig says: wee wee\");\n  }\n}\n\nclass Dog : Animal  \/\/ Derived class (child) \n{\n  public void animalSound() \n  {\n    Console.WriteLine(\"The dog says: bow wow\");\n  }\n}<\/code><\/pre>\n\n\n\n<p>Remember from the\u00a0<a href=\"https:\/\/www.w3schools.com\/cs\/cs_inheritance.php\">Inheritance chapter<\/a>\u00a0that we use the\u00a0<code>:<\/code>\u00a0symbol to inherit from a class.<\/p>\n\n\n\n<p>Now we can create\u00a0<code>Pig<\/code>\u00a0and\u00a0<code>Dog<\/code>\u00a0objects and call the\u00a0<code>animalSound()<\/code>\u00a0method on both of them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal  \/\/ Base class (parent) \n{\n  public void animalSound() \n  {\n    Console.WriteLine(\"The animal makes a sound\");\n  }\n}\n\nclass Pig : Animal  \/\/ Derived class (child) \n{\n  public void animalSound() \n  {\n    Console.WriteLine(\"The pig says: wee wee\");\n  }\n}\n\nclass Dog : Animal  \/\/ Derived class (child) \n{\n  public void animalSound() \n  {\n    Console.WriteLine(\"The dog says: bow wow\");\n  }\n}\n\nclass Program \n{\n  static void Main(string&#91;] args) \n  {\n    Animal myAnimal = new Animal();  \/\/ Create a Animal object\n    Animal myPig = new Pig();  \/\/ Create a Pig object\n    Animal myDog = new Dog();  \/\/ Create a Dog object\n\n    myAnimal.animalSound();\n    myPig.animalSound();\n    myDog.animalSound();\n  }\n}<\/code><\/pre>\n\n\n\n<p>The output will be: <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u3010\u2588\u2588\u2588\u2588 C# \u4e2d\u4e3a\u4ec0\u4e48\u8fd9\u6837\u8f93\u51fa\u5462\uff1f\u56e0\u4e3a\u4f60\u521b\u5efa\u4e86\u4e0d\u540c\u7684\u5b50\u7c7b\u5bf9\u8c61\uff0c\u4f46\u662f\u662f\u7528\u7236\u7c7b\u7684\u5f15\u7528\u63a5\u6536\u7684\uff01\uff01\u6240\u4ee5\u4f1a\u4f18\u5148\u8c03\u7528\u7236\u5f15\u7528\u4e2d\u7684\u65b9\u6cd5\uff01\u3011<\/mark><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The animal makes a sound\nThe animal makes a sound\nThe animal makes a sound<\/code><\/pre>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u548c\u4e0a\u9762\u4e00\u6a21\u4e00\u6837\u7684 Java \u4ee3\u7801\uff0c\u80fd\u81ea\u52a8\u5b9e\u73b0\u591a\u6001\uff08\u5982\u4e0b\uff09\uff0c\u4e0d\u9700\u8981\u52a0 virtual\u3001override \u5173\u952e\u5b57\uff1a<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"844\" height=\"355\" src=\"http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/image-16.png\" alt=\"\" class=\"wp-image-1486\" srcset=\"http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/image-16.png 844w, http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/image-16-300x126.png 300w, http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/image-16-768x323.png 768w\" sizes=\"(max-width: 844px) 100vw, 844px\" \/><\/a><\/figure>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u81f3\u4e8e\u4e3a\u4ec0\u4e48 C# \u4e2d\u7684\u591a\u6001\u8fd9\u6837\u5b9e\u73b0\uff0c\u89c1\u6700\u4e0b\u65b9\u5206\u6790\u3002<\/mark><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C# \u4e2d\u5982\u679c\u60f3\u8fbe\u5230\u60f3\u4e0a\u9762 Java \u4e2d\u7684\u6548\u679c\uff0c\u5f97\u4f7f\u7528 virtual\u3001override \u5173\u952e\u5b57\uff01\uff01\uff01<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Not The Output I Was Looking For<\/h3>\n\n\n\n<p>The output from the example above was probably not what you expected. <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">That is because the base class method overrides the derived class method, when they share the same name<\/mark><\/strong>.<\/p>\n\n\n\n<p>However, C# provides an option to override the base class method, by adding the&nbsp;<code>virtual<\/code>&nbsp;keyword to the method inside the base class, and by using the&nbsp;<code>override<\/code>&nbsp;keyword for each derived class methods:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class Animal  \/\/ Base class (parent) \n{\n  public virtual void animalSound() <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\/\/\u2588\u2588 \u7236\u7c7b\u4e2d\u4f7f\u7528 virtual \u4fee\u9970\u65b9\u6cd5\uff01\uff01\uff01<\/mark><\/strong>\n  {\n    Console.WriteLine(\"The animal makes a sound\");\n  }\n}\n\nclass Pig : Animal  \/\/ Derived class (child) \n{\n  public override void animalSound() <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\/\/\u2588\u2588 \u5b50\u7c7b\u4e2d\u4f7f\u7528 override \u4fee\u9970\u65b9\u6cd5\uff01\uff01\uff01<\/mark><\/strong>\n  {\n    Console.WriteLine(\"The pig says: wee wee\");\n  }\n}\n\nclass Dog : Animal  \/\/ Derived class (child) \n{\n  public override void animalSound() \n  {\n    Console.WriteLine(\"The dog says: bow wow\");\n  }\n}\n\nclass Program \n{\n  static void Main(string&#91;] args) \n  {\n    Animal myAnimal = new Animal();  \/\/ Create a Animal object\n    Animal myPig = new Pig();  \/\/ Create a Pig object\n    Animal myDog = new Dog();  \/\/ Create a Dog object\n\n    myAnimal.animalSound();\n    myPig.animalSound();\n    myDog.animalSound();\n  }\n}<\/code><\/pre>\n\n\n\n<p>The output will be:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The animal makes a sound\nThe pig says: wee wee\nThe dog says: bow wow<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Why And When To Use &#8220;Inheritance&#8221; and &#8220;Polymorphism&#8221;?<\/h4>\n\n\n\n<p>&#8211; It is useful for code reusability: reuse fields and methods of an existing class when you create a new class.<\/p>\n\n\n\n<p>\u4ece\u4e0a\u9762\u53ef\u4ee5\u770b\u51fa\uff0cC# \u4e2d\u7684\u591a\u6001\u548c Java \u4e2d\u7684\u591a\u6001\u662f\u6709\u533a\u522b\u7684\uff0c\u4e3a\u4ec0\u4e48 C# \u4e2d\u7684\u591a\u6001\u8fd9\u6837\u5b9e\u73b0\u5462\uff1f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C# \u4e2d\u4e3a\u4ec0\u4e48\u8981\u52a0\u5165 virtual\u3001override \u5173\u952e\u5b57\uff1f\u800c\u4e0d\u662f\u50cf Java \u90a3\u6837\u5b9e\u73b0\u591a\u6001\uff1f<\/h2>\n\n\n\n<p>\u5728 C# \u4e2d\u5f15\u5165\u00a0<code>virtual<\/code>\u00a0\u548c\u00a0<code>override<\/code>\u00a0\u5173\u952e\u5b57<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u662f\u4e3a\u4e86\u66f4\u660e\u786e\u5730\u63a7\u5236\u65b9\u6cd5\u7684\u591a\u6001\u884c\u4e3a<\/mark><\/strong>\uff0c\u540c\u65f6\u63d0\u4f9b\u66f4\u9ad8\u7684\u7075\u6d3b\u6027\u548c\u5b89\u5168\u6027\u3002\u8fd9\u4e0e Java \u7684\u8bbe\u8ba1\u54f2\u5b66\u6709\u6240\u4e0d\u540c\uff0c\u4ee5\u4e0b\u662f\u5177\u4f53\u539f\u56e0\uff1a<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">1.&nbsp;<strong>\u660e\u786e\u591a\u6001\u884c\u4e3a\u7684\u610f\u56fe<\/strong><\/h3>\n\n\n\n<ul>\n<li>\u5728 C# \u4e2d\uff0c<strong><code>virtual<\/code><\/strong>\u00a0\u5173\u952e\u5b57\u7528\u4e8e\u6807\u8bb0\u4e00\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u88ab\u6d3e\u751f\u7c7b\u91cd\u5199\uff0c\u800c\u00a0<strong><code>override<\/code><\/strong>\u00a0\u5173\u952e\u5b57\u7528\u4e8e\u660e\u786e\u8868\u793a\u6d3e\u751f\u7c7b\u6b63\u5728\u91cd\u5199\u57fa\u7c7b\u7684\u865a\u65b9\u6cd5\u3002<\/li>\n\n\n\n<li><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u8fd9\u79cd\u8bbe\u8ba1\u4f7f\u5f97\u4ee3\u7801\u7684\u610f\u56fe\u66f4\u52a0\u6e05\u6670\uff1a\u5f00\u53d1\u8005\u53ef\u4ee5\u6e05\u695a\u5730\u77e5\u9053\u54ea\u4e9b\u65b9\u6cd5\u662f\u8bbe\u8ba1\u4e3a\u53ef\u91cd\u5199\u7684\uff0c\u54ea\u4e9b\u65b9\u6cd5\u662f\u660e\u786e\u88ab\u91cd\u5199\u7684\u3002<\/mark><\/strong><\/li>\n\n\n\n<li><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\"><strong>\u76f8\u6bd4\u4e4b\u4e0b\uff0cJava \u9ed8\u8ba4\u6240\u6709\u975e\u9759\u6001\u65b9\u6cd5\u90fd\u662f\u865a\u65b9\u6cd5\uff08\u9664\u975e\u7528\u00a0<code>final<\/code>\u00a0\u4fee\u9970\uff09\uff0c\u8fd9\u79cd\u8bbe\u8ba1\u867d\u7136\u7b80\u5316\u4e86\u8bed\u6cd5\uff0c\u4f46\u53ef\u80fd\u5bfc\u81f4\u5f00\u53d1\u8005\u65e0\u610f\u4e2d\u91cd\u5199\u65b9\u6cd5\uff0c\u589e\u52a0\u4e86\u4ee3\u7801\u7684\u4e0d\u53ef\u63a7\u6027\u3002<\/strong><\/mark><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">2.&nbsp;<strong>\u907f\u514d\u610f\u5916\u7684\u91cd\u5199<\/strong><\/h3>\n\n\n\n<ul>\n<li><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">C# \u7684\u8bbe\u8ba1\u8981\u6c42\u663e\u5f0f\u4f7f\u7528\u00a0<code>virtual<\/code>\u00a0\u548c\u00a0<code>override<\/code>\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u6d3e\u751f\u7c7b\u65e0\u610f\u4e2d\u91cd\u5199\u57fa\u7c7b\u65b9\u6cd5\u7684\u60c5\u51b5\u3002<\/mark><\/strong><\/li>\n\n\n\n<li>\u5728 Java \u4e2d\uff0c\u5982\u679c\u57fa\u7c7b\u7684\u65b9\u6cd5\u6ca1\u6709\u88ab\u6807\u8bb0\u4e3a\u00a0<code>final<\/code>\uff0c\u6d3e\u751f\u7c7b\u53ef\u4ee5\u76f4\u63a5\u91cd\u5199\u5b83\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u610f\u5916\u7684\u884c\u4e3a\uff0c\u5c24\u5176\u662f\u5728\u5927\u578b\u9879\u76ee\u4e2d\u3002<\/li>\n\n\n\n<li>C# \u7684\u8fd9\u79cd\u8bbe\u8ba1\u63d0\u9ad8\u4e86\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">3.&nbsp;<strong>\u652f\u6301\u65b9\u6cd5\u9690\u85cf\uff08Method Hiding\uff09<\/strong><\/h3>\n\n\n\n<ul>\n<li>C# \u63d0\u4f9b\u4e86\u00a0<strong><code>new<\/code><\/strong>\u00a0\u5173\u952e\u5b57\uff0c\u7528\u4e8e\u9690\u85cf\u57fa\u7c7b\u7684\u65b9\u6cd5\uff08\u800c\u4e0d\u662f\u91cd\u5199\uff09\u3002\u8fd9\u79cd\u884c\u4e3a\u4e0e Java \u4e0d\u540c\uff0c\u5141\u8bb8\u5f00\u53d1\u8005\u5728\u6d3e\u751f\u7c7b\u4e2d\u5b9a\u4e49\u4e0e\u57fa\u7c7b\u540c\u540d\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u4f1a\u5f71\u54cd\u57fa\u7c7b\u7684\u884c\u4e3a\u3002<\/li>\n\n\n\n<li>\u8fd9\u79cd\u8bbe\u8ba1\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u975e\u5e38\u6709\u7528\uff0c\u4f8b\u5982\u5f53\u6d3e\u751f\u7c7b\u9700\u8981\u5b9e\u73b0\u4e0e\u57fa\u7c7b\u540c\u540d\u4f46\u884c\u4e3a\u4e0d\u540c\u7684\u65b9\u6cd5\u65f6\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">4.&nbsp;<strong>\u6027\u80fd\u4f18\u5316<\/strong><\/h3>\n\n\n\n<ul>\n<li><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">C# \u7684\u8bbe\u8ba1\u5141\u8bb8\u7f16\u8bd1\u5668\u66f4\u597d\u5730\u4f18\u5316\u4ee3\u7801\u3002<\/mark><\/strong>\u7531\u4e8e\u865a\u65b9\u6cd5\u7684\u8c03\u7528\u9700\u8981\u901a\u8fc7\u865a\u8868\uff08vtable\uff09\u8fdb\u884c\u52a8\u6001\u5206\u6d3e\uff0c\u6027\u80fd\u4e0a\u4f1a\u6709\u4e00\u5b9a\u7684\u5f00\u9500\u3002<\/li>\n\n\n\n<li>\u901a\u8fc7\u663e\u5f0f\u6807\u8bb0\u00a0<code>virtual<\/code>\u00a0\u548c\u00a0<code>override<\/code>\uff0cC# \u53ef\u4ee5\u8ba9\u5f00\u53d1\u8005\u66f4\u6e05\u695a\u5730\u77e5\u9053\u54ea\u4e9b\u65b9\u6cd5\u662f\u865a\u65b9\u6cd5\uff0c\u4ece\u800c\u5728\u6027\u80fd\u654f\u611f\u7684\u573a\u666f\u4e2d\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u865a\u65b9\u6cd5\u8c03\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">5.&nbsp;<strong>\u4e0e C++ \u7684\u8bbe\u8ba1\u54f2\u5b66\u4e00\u81f4<\/strong><\/h3>\n\n\n\n<ul>\n<li><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">C# \u7684\u8bbe\u8ba1\u53d7\u5230\u4e86 C++ \u7684\u5f71\u54cd\u3002\u5728 C++ \u4e2d\uff0c\u865a\u65b9\u6cd5\u4e5f\u9700\u8981\u663e\u5f0f\u6807\u8bb0\u4e3a\u00a0<code>virtual<\/code>\uff0c\u800c\u6d3e\u751f\u7c7b\u9700\u8981\u663e\u5f0f\u91cd\u5199\u3002<\/mark><\/li>\n\n\n\n<li>\u8fd9\u79cd\u8bbe\u8ba1\u54f2\u5b66\u5f3a\u8c03\u663e\u5f0f\u6027\u548c\u53ef\u63a7\u6027\uff0c\u4e0e Java \u7684\u9690\u5f0f\u591a\u6001\u8bbe\u8ba1\u5f62\u6210\u5bf9\u6bd4\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">6.&nbsp;<strong>Java \u7684\u8bbe\u8ba1\u54f2\u5b66<\/strong><\/h3>\n\n\n\n<ul>\n<li><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">Java \u7684\u8bbe\u8ba1\u66f4\u503e\u5411\u4e8e\u7b80\u5316\u8bed\u6cd5\u548c\u964d\u4f4e\u5b66\u4e60\u95e8\u69db\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6240\u6709\u975e\u9759\u6001\u65b9\u6cd5\u90fd\u662f\u865a\u65b9\u6cd5\uff0c\u9664\u975e\u7528\u00a0<code>final<\/code>\u00a0\u4fee\u9970\u3002<\/mark><\/strong><\/li>\n\n\n\n<li>\u8fd9\u79cd\u8bbe\u8ba1\u867d\u7136\u7b80\u5316\u4e86\u4ee3\u7801\uff0c\u4f46\u4e5f\u53ef\u80fd\u5bfc\u81f4\u4e00\u4e9b\u95ee\u9898\uff0c\u4f8b\u5982\uff1a\n<ul>\n<li>\u5f00\u53d1\u8005\u53ef\u80fd\u65e0\u610f\u4e2d\u91cd\u5199\u57fa\u7c7b\u65b9\u6cd5\u3002<\/li>\n\n\n\n<li>\u7f3a\u4e4f\u5bf9\u65b9\u6cd5\u9690\u85cf\u7684\u663e\u5f0f\u652f\u6301\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p>C# \u5f15\u5165&nbsp;<code>virtual<\/code>&nbsp;\u548c&nbsp;<code>override<\/code>&nbsp;\u5173\u952e\u5b57\u7684\u4e3b\u8981\u76ee\u7684\u662f\u4e3a\u4e86\u63d0\u4f9b\u66f4\u660e\u786e\u3001\u66f4\u5b89\u5168\u7684\u591a\u6001\u673a\u5236\u3002\u8fd9\u79cd\u8bbe\u8ba1\u5f3a\u8c03\u663e\u5f0f\u6027\u548c\u53ef\u63a7\u6027\uff0c\u907f\u514d\u4e86\u610f\u5916\u7684\u91cd\u5199\u884c\u4e3a\uff0c\u540c\u65f6\u652f\u6301\u65b9\u6cd5\u9690\u85cf\u548c\u6027\u80fd\u4f18\u5316\u3002\u76f8\u6bd4\u4e4b\u4e0b\uff0cJava \u7684\u8bbe\u8ba1\u66f4\u6ce8\u91cd\u7b80\u6d01\u6027\uff0c\u4f46\u53ef\u80fd\u5728\u5927\u578b\u9879\u76ee\u4e2d\u5e26\u6765\u4e00\u4e9b\u4e0d\u53ef\u63a7\u7684\u98ce\u9669\u3002\u4e24\u79cd\u8bed\u8a00\u7684\u8bbe\u8ba1\u54f2\u5b66\u5404\u6709\u4f18\u52a3\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u5f00\u53d1\u573a\u666f\u3002<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>C#\u00a0Inheritance Inheritance (Derived and Base Class) \u6d3e\u751f\u7c7b&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1464,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[60],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001 - \u7801\u5148\u751f\u7684\u535a\u5ba2<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08oop\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001 - \u7801\u5148\u751f\u7684\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"C#\u00a0Inheritance Inheritance (Derived and Base Class) \u6d3e\u751f\u7c7b...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08oop\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001\/\" \/>\n<meta property=\"og:site_name\" content=\"\u7801\u5148\u751f\u7684\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-08T17:24:37+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-08T17:24:39+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/csharp1-\u526f\u672c.png\" \/>\n\t<meta property=\"og:image:width\" content=\"489\" \/>\n\t<meta property=\"og:image:height\" content=\"468\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"\u7801\u5148\u751f\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/mrcode2021\" \/>\n<meta name=\"twitter:site\" content=\"@mrcode2021\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u7801\u5148\u751f\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#article\",\"isPartOf\":{\"@id\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/\"},\"author\":{\"name\":\"\u7801\u5148\u751f\",\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"headline\":\"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001\",\"datePublished\":\"2025-03-08T17:24:37+00:00\",\"dateModified\":\"2025-03-08T17:24:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/\"},\"wordCount\":457,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"keywords\":[\"csharp\"],\"articleSection\":[\"C#\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/\",\"url\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/\",\"name\":\"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001 - \u7801\u5148\u751f\u7684\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"http:\/\/codermr.com\/#website\"},\"datePublished\":\"2025-03-08T17:24:37+00:00\",\"dateModified\":\"2025-03-08T17:24:39+00:00\",\"breadcrumb\":{\"@id\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"http:\/\/codermr.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/codermr.com\/#website\",\"url\":\"http:\/\/codermr.com\/\",\"name\":\"\u7801\u5148\u751f\u7684\u535a\u5ba2\",\"description\":\"\u6b22 \u8fce \u4e0b \u8f7d \u6211 \u5f00 \u53d1 \u7684 \u5404 \u7aef \u8f6f \u4ef6 \u548c APP\",\"publisher\":{\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/codermr.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\",\"name\":\"\u7801\u5148\u751f\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg\",\"contentUrl\":\"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg\",\"width\":400,\"height\":400,\"caption\":\"\u7801\u5148\u751f\"},\"logo\":{\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"http:\/\/codermr.com\",\"https:\/\/twitter.com\/https:\/\/twitter.com\/mrcode2021\"],\"url\":\"http:\/\/codermr.com\/index.php\/author\/coderma\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001 - \u7801\u5148\u751f\u7684\u535a\u5ba2","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":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08oop\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001\/","og_locale":"zh_CN","og_type":"article","og_title":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001 - \u7801\u5148\u751f\u7684\u535a\u5ba2","og_description":"C#\u00a0Inheritance Inheritance (Derived and Base Class) \u6d3e\u751f\u7c7b...","og_url":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08oop\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001\/","og_site_name":"\u7801\u5148\u751f\u7684\u535a\u5ba2","article_published_time":"2025-03-08T17:24:37+00:00","article_modified_time":"2025-03-08T17:24:39+00:00","og_image":[{"width":489,"height":468,"url":"http:\/\/codermr.com\/wp-content\/uploads\/2025\/03\/csharp1-\u526f\u672c.png","type":"image\/png"}],"author":"\u7801\u5148\u751f","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/mrcode2021","twitter_site":"@mrcode2021","twitter_misc":{"\u4f5c\u8005":"\u7801\u5148\u751f","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#article","isPartOf":{"@id":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/"},"author":{"name":"\u7801\u5148\u751f","@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"headline":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001","datePublished":"2025-03-08T17:24:37+00:00","dateModified":"2025-03-08T17:24:39+00:00","mainEntityOfPage":{"@id":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/"},"wordCount":457,"commentCount":0,"publisher":{"@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"keywords":["csharp"],"articleSection":["C#"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#respond"]}]},{"@type":"WebPage","@id":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/","url":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/","name":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001 - \u7801\u5148\u751f\u7684\u535a\u5ba2","isPartOf":{"@id":"http:\/\/codermr.com\/#website"},"datePublished":"2025-03-08T17:24:37+00:00","dateModified":"2025-03-08T17:24:39+00:00","breadcrumb":{"@id":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e4%b8%89%ef%bc%88oop%ef%bc%89%ef%bc%9a%e7%bb%a7%e6%89%bf%e3%80%81%e5%a4%9a%e6%80%81\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"http:\/\/codermr.com\/"},{"@type":"ListItem","position":2,"name":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u4e09\uff08OOP\uff09\uff1a\u7ee7\u627f\u3001\u591a\u6001"}]},{"@type":"WebSite","@id":"http:\/\/codermr.com\/#website","url":"http:\/\/codermr.com\/","name":"\u7801\u5148\u751f\u7684\u535a\u5ba2","description":"\u6b22 \u8fce \u4e0b \u8f7d \u6211 \u5f00 \u53d1 \u7684 \u5404 \u7aef \u8f6f \u4ef6 \u548c APP","publisher":{"@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/codermr.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf","name":"\u7801\u5148\u751f","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"http:\/\/codermr.com\/#\/schema\/person\/image\/","url":"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg","contentUrl":"http:\/\/codermr.com\/wp-content\/uploads\/2023\/02\/wukong.jpg","width":400,"height":400,"caption":"\u7801\u5148\u751f"},"logo":{"@id":"http:\/\/codermr.com\/#\/schema\/person\/image\/"},"sameAs":["http:\/\/codermr.com","https:\/\/twitter.com\/https:\/\/twitter.com\/mrcode2021"],"url":"http:\/\/codermr.com\/index.php\/author\/coderma\/"}]}},"_links":{"self":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/1481"}],"collection":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/comments?post=1481"}],"version-history":[{"count":8,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/1481\/revisions"}],"predecessor-version":[{"id":1491,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/1481\/revisions\/1491"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/media\/1464"}],"wp:attachment":[{"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/media?parent=1481"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/categories?post=1481"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/tags?post=1481"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}