{"id":1492,"date":"2025-03-09T01:59:17","date_gmt":"2025-03-08T17:59:17","guid":{"rendered":"http:\/\/codermr.com\/?p=1492"},"modified":"2025-03-09T01:59:18","modified_gmt":"2025-03-08T17:59:18","slug":"c%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%e6%b1%87%e6%80%bb%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3","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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/","title":{"rendered":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">C#\u00a0Abstraction<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">Abstract Classes and Methods<\/h2>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">Data\u00a0<strong>abstraction<\/strong><\/mark>\u00a0is the process of <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">hiding certain details and showing only essential information to the user<\/mark>.<br>Abstraction can be achieved with either\u00a0<strong>abstract classes<\/strong>\u00a0or\u00a0<a href=\"https:\/\/www.w3schools.com\/cs\/cs_interface.php\"><strong>interfaces<\/strong><\/a>\u00a0(which you will learn more about in the next chapter).  <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u3010\u201c\u62bd\u8c61\u201d\u53ef\u4ee5\u901a\u8fc7&#8221;\u62bd\u8c61\u7c7b&#8221;\u548c&#8221;\u63a5\u53e3&#8221;\u5b9e\u73b0\u3011<\/mark><\/strong><\/p>\n\n\n\n<p>The&nbsp;<code>abstract<\/code>&nbsp;keyword is used for classes and methods:<\/p>\n\n\n\n<ul>\n<li><strong>Abstract class:<\/strong>\u00a0is a restricted class that cannot be used to create objects (to access it, it must be inherited from another class).<\/li>\n\n\n\n<li><strong>Abstract method:<\/strong>\u00a0can only be used in an abstract class, and it does not have a body. The body is provided by the derived class (inherited from).<\/li>\n<\/ul>\n\n\n\n<p>An abstract class can have both abstract and regular methods:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abstract class Animal \n{\n  public abstract void animalSound();\n  public void sleep() \n  {\n    Console.WriteLine(\"Zzz\");\n  }\n}<\/code><\/pre>\n\n\n\n<p>From the example above, it is not possible to create an object of the Animal class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Animal myObj = new Animal(); \/\/ Will generate an error (Cannot create an instance of the abstract class or interface 'Animal')<\/code><\/pre>\n\n\n\n<p>To access the abstract class, it must be inherited from another class. Let&#8217;s convert the Animal class we used in the&nbsp;<a href=\"https:\/\/www.w3schools.com\/cs\/cs_polymorphism.php\">Polymorphism<\/a>&nbsp;chapter to an abstract class.<\/p>\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, and that we use the\u00a0<code>override<\/code>\u00a0keyword to override the base class method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Abstract class\nabstract class Animal\n{\n  \/\/ Abstract method (does not have a body)\n  public abstract void animalSound();\n  \/\/ Regular method\n  public void sleep()\n  {\n    Console.WriteLine(\"Zzz\");\n  }\n}\n\n\/\/ Derived class (inherit from Animal)\nclass Pig : Animal\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\u8981\u5b9e\u73b0\u62bd\u8c61\u7c7b\u4e2d\u7684\u65b9\u6cd5\uff0c\u5bf9\u5b50\u7c7b\u4e2d\u7684\u65b9\u6cd5\u8fd8\u662f\u8981\u7528 override \u4fee\u9970\uff01\uff01\uff01<\/mark><\/strong>\n  {\n    \/\/ The body of animalSound() is provided here\n    Console.WriteLine(\"The pig says: wee wee\");\n  }\n}\n\nclass Program\n{\n  static void Main(string&#91;] args)\n  {\n    Pig myPig = new Pig(); \/\/ Create a Pig object\n    myPig.animalSound();  \/\/ Call the abstract method\n    myPig.sleep();  \/\/ Call the regular method\n  }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Why And When To Use Abstract Classes and Methods?<\/h4>\n\n\n\n<p>To achieve security &#8211; hide certain details and only show the important details of an object.<\/p>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;Abstraction can also be achieved with&nbsp;<a href=\"https:\/\/www.w3schools.com\/cs\/cs_interface.php\">Interfaces<\/a>, which you will learn more about in the next chapter.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">C#\u00a0Interface<\/h1>\n\n\n\n<p><span style=\"color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;\">An<span>\u00a0<\/span><\/span><code class=\"w3-codespan\" style=\"box-sizing: inherit; font-family: Consolas, Menlo, &quot;courier new&quot;, monospace; font-size: 15.75px; color: crimson; background-color: rgba(222, 222, 222, 0.3); padding-left: 4px; padding-right: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\">interface<\/code><span style=\"color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;\"><span>\u00a0<\/span>is a completely &#8220;<\/span><strong style=\"box-sizing: inherit; font-weight: bolder; color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;\">abstract class<\/strong><span style=\"color: rgb(0, 0, 0); font-family: Verdana, sans-serif; font-size: 15px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;\">&#8220;, which can only contain abstract methods and properties (with empty bodies):<\/span>\u00a0 <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u3010\u63a5\u53e3\u662f\u4e00\u4e2a\u5b8c\u5168\u7684\u201c\u62bd\u8c61\u7c7b\u201d\uff0c\u5b83\u53ea\u80fd\u5305\u542b\u62bd\u8c61\u65b9\u6cd5\u548c\u5c5e\u6027\uff08\u5177\u6709\u7a7a\u4f53\uff09\uff01\uff1f\uff1f\u3011<\/mark><\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ interface\ninterface Animal \n{\n  void animalSound(); \/\/ interface method (does not have a body)\n  void run(); \/\/ interface method (does not have a body)\n}<\/code><\/pre>\n\n\n\n<p>It is considered good practice to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">start with the letter &#8220;I&#8221; at the beginning of an interface<\/mark>, as it makes it easier for yourself and others to remember that it is an interface and not a class.<\/p>\n\n\n\n<p>By default, members of an interface are&nbsp;<code>abstract<\/code>&nbsp;and&nbsp;<code>public<\/code>.<\/p>\n\n\n\n<p style=\"font-size:27px\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">Note:\u00a0Interfaces can contain properties and methods, but not fields.<\/mark><\/strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\u2588\u2588\u2588\u2588<\/mark><\/p>\n\n\n\n<p>To access the interface methods, the interface must be &#8220;implemented&#8221; (kinda like inherited) by another class. To implement an interface, use the&nbsp;<code>:<\/code>&nbsp;symbol (just like with inheritance). The body of the interface method is provided by the &#8220;implement&#8221; class. Note that you do not have to use the&nbsp;<code>override<\/code>&nbsp;keyword when implementing an interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Interface\ninterface IAnimal \n{\n  void animalSound(); <strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">\/\/\u2588\u2588 interface method (does not have a body)<\/mark><\/strong>\n}\n\n\/\/ Pig \"implements\" the IAnimal interface\nclass Pig : IAnimal \n{\n  public void animalSound() \n  {\n    \/\/ The body of animalSound() is provided here\n    Console.WriteLine(\"The pig says: wee wee\");\n  }\n}\n\nclass Program \n{\n  static void Main(string&#91;] args) \n  {\n    Pig myPig = new Pig();  \/\/ Create a Pig object\n    myPig.animalSound();\n  }\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Notes on Interfaces:<\/h4>\n\n\n\n<ul>\n<li>Like\u00a0<strong>abstract classes<\/strong>, interfaces\u00a0<strong>cannot<\/strong>\u00a0be used to create objects (in the example above, it is not possible to create an &#8220;IAnimal&#8221; object in the Program class)<\/li>\n\n\n\n<li>Interface methods do not have a body &#8211; the body is provided by the &#8220;implement&#8221; class<\/li>\n\n\n\n<li>On implementation of an interface, you must override all of its methods<\/li>\n\n\n\n<li>Interfaces can contain properties and methods, but not fields\/variables<\/li>\n\n\n\n<li>Interface members are by default\u00a0<code>abstract<\/code>\u00a0and\u00a0<code>public<\/code><\/li>\n\n\n\n<li>An interface cannot contain a constructor (as it cannot be used to create objects)<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Why And When To Use Interfaces?<\/h4>\n\n\n\n<p>1) To achieve security &#8211; hide certain details and only show the important details of an object (interface).<\/p>\n\n\n\n<p>2) C# does not support &#8220;multiple inheritance&#8221; (a class can only inherit from one base class). However, it can be achieved with interfaces, because the class can&nbsp;<strong>implement<\/strong>&nbsp;multiple interfaces.&nbsp;<strong>Note:<\/strong>&nbsp;To implement multiple interfaces, separate them with a comma (see example in the next chapter).<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Multiple Interfaces<\/h1>\n\n\n\n<p>To implement multiple interfaces, separate them with a comma:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>interface IFirstInterface \n{\n  void myMethod(); \/\/ interface method\n}\n\ninterface ISecondInterface \n{\n  void myOtherMethod(); \/\/ interface method\n}\n\n\/\/ Implement multiple interfaces\nclass DemoClass : IFirstInterface, ISecondInterface \n{\n  public void myMethod() \n  {\n    Console.WriteLine(\"Some text..\");\n  }\n  public void myOtherMethod() \n  {\n    Console.WriteLine(\"Some other text...\");\n  }\n}\n\nclass Program \n{\n  static void Main(string&#91;] args)\n  {\n    DemoClass myObj = new DemoClass();\n    myObj.myMethod();\n    myObj.myOtherMethod();\n  }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>C#\u00a0Abstraction Abstract Classes and Methods Data\u00a0abstra&#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\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3 - \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\u56db\uff08oop\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3\/\" \/>\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\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3 - \u7801\u5148\u751f\u7684\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"C#\u00a0Abstraction Abstract Classes and Methods Data\u00a0abstra...\" \/>\n<meta property=\"og:url\" content=\"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08oop\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3\/\" \/>\n<meta property=\"og:site_name\" content=\"\u7801\u5148\u751f\u7684\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-08T17:59:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-08T17:59:18+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=\"5 \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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/\"},\"author\":{\"name\":\"\u7801\u5148\u751f\",\"@id\":\"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf\"},\"headline\":\"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3\",\"datePublished\":\"2025-03-08T17:59:17+00:00\",\"dateModified\":\"2025-03-08T17:59:18+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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/\"},\"wordCount\":537,\"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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/\",\"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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/\",\"name\":\"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3 - \u7801\u5148\u751f\u7684\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"http:\/\/codermr.com\/#website\"},\"datePublished\":\"2025-03-08T17:59:17+00:00\",\"dateModified\":\"2025-03-08T17:59:18+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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/\"]}]},{\"@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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3\"}]},{\"@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\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3 - \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\u56db\uff08oop\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3\/","og_locale":"zh_CN","og_type":"article","og_title":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3 - \u7801\u5148\u751f\u7684\u535a\u5ba2","og_description":"C#\u00a0Abstraction Abstract Classes and Methods Data\u00a0abstra...","og_url":"http:\/\/codermr.com\/index.php\/2025\/03\/09\/c\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08oop\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3\/","og_site_name":"\u7801\u5148\u751f\u7684\u535a\u5ba2","article_published_time":"2025-03-08T17:59:17+00:00","article_modified_time":"2025-03-08T17:59:18+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":"5 \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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/"},"author":{"name":"\u7801\u5148\u751f","@id":"http:\/\/codermr.com\/#\/schema\/person\/39016e15c79e4f02d1ed3a64688619bf"},"headline":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3","datePublished":"2025-03-08T17:59:17+00:00","dateModified":"2025-03-08T17:59:18+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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/"},"wordCount":537,"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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/","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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/","name":"C#\u57fa\u7840\u77e5\u8bc6\u6c47\u603b\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3 - \u7801\u5148\u751f\u7684\u535a\u5ba2","isPartOf":{"@id":"http:\/\/codermr.com\/#website"},"datePublished":"2025-03-08T17:59:17+00:00","dateModified":"2025-03-08T17:59:18+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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/"]}]},{"@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%e5%9b%9b%ef%bc%88oop%ef%bc%89%ef%bc%9a%e6%8a%bd%e8%b1%a1%e3%80%81%e6%8e%a5%e5%8f%a3\/#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\u56db\uff08OOP\uff09\uff1a\u62bd\u8c61\u3001\u63a5\u53e3"}]},{"@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\/1492"}],"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=1492"}],"version-history":[{"count":4,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/1492\/revisions"}],"predecessor-version":[{"id":1496,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/posts\/1492\/revisions\/1496"}],"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=1492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/categories?post=1492"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/codermr.com\/index.php\/wp-json\/wp\/v2\/tags?post=1492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}