{"id":1572,"date":"2023-04-15T10:45:51","date_gmt":"2023-04-15T03:45:51","guid":{"rendered":"https:\/\/csharptutorial.net\/?page_id=1572"},"modified":"2023-05-13T14:58:35","modified_gmt":"2023-05-13T07:58:35","slug":"csharp-adapter-pattern","status":"publish","type":"page","link":"https:\/\/www.csharptutorial.net\/csharp-design-patterns\/csharp-adapter-pattern\/","title":{"rendered":"C# Adapter Pattern"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn how to use the C# Adapter pattern to enable classes of incompatible interfaces to work together.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the C# Adapter pattern<\/h2>\n\n\n\n<p>The Adapter pattern converts an interface into another interface that clients expect. The Adapter pattern allows classes of incompatible <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-interface\/\">interfaces<\/a> to work together.<\/p>\n\n\n\n<p>Suppose you&#8217;re traveling to a foreign country and you want to charge your phone. The problem is that the electric socket in that country has a different shape than your phone charger&#8217;s plug.<\/p>\n\n\n\n<p>To solve this problem, you can use an adapter that converts the foreign socket into your phone charger&#8217;s plug shape. <\/p>\n\n\n\n<p>This adapter serves as a wrapper that translates the interface of the foreign socket into the interface that your phone charger expects. By doing this, you can charge your phone without changing the foreign socket.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"803\" height=\"310\" src=\"https:\/\/csharptutorial.net\/wp-content\/uploads\/2023\/04\/adapter.png\" alt=\"C# Adapter Pattern\" class=\"wp-image-1582\" srcset=\"https:\/\/www.csharptutorial.net\/wp-content\/uploads\/2023\/04\/adapter.png 803w, https:\/\/www.csharptutorial.net\/wp-content\/uploads\/2023\/04\/adapter-300x116.png 300w, https:\/\/www.csharptutorial.net\/wp-content\/uploads\/2023\/04\/adapter-768x296.png 768w\" sizes=\"auto, (max-width: 803px) 100vw, 803px\" \/><\/figure>\n\n\n\n<p>Similarly, the Adapter pattern creates an adapter that converts the interface of an object into an interface that clients expect, allowing them to work together without modifying their code.<\/p>\n\n\n\n<p>The Adapter pattern has two variants: object adapter and class adapter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Object Adapter<\/h2>\n\n\n\n<p>The following UML diagram illustrates the object adapter:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/csharptutorial.net\/wp-content\/uploads\/2023\/04\/CSharp-Object-Adapter-Pattern-1.svg\" alt=\"C# Object Adapter Pattern\" class=\"wp-image-1576\"\/><\/figure>\n\n\n\n<p>In this Object Adapter UML diagram:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ITarget<\/code> interface: This is the interface that the client expects to work with. It&#8217;s also the interface that the <code>Adapter<\/code> class will implement.<\/li>\n\n\n\n<li><code>Adaptee<\/code>: is the class that has an interface that is not compatible with the <code>ITarget<\/code> interface. It is the class that the <code>Adapter<\/code> class will wrap and adapt.<\/li>\n\n\n\n<li><code>Adapter<\/code>: is the class that implements the target interface and wraps the <code>Adaptee<\/code> object. The <code>Adapter<\/code> class is responsible for translating the calls from the <code>ITarget<\/code> interface to the <code>Adaptee<\/code>&#8216;s interface and delegating the work to it.<\/li>\n<\/ul>\n\n\n\n<p>In this pattern, the <code>Adapter<\/code> has a member which is the <code>Adaptee<\/code> object. The <code>Operation()<\/code> method of the <code>Adapter<\/code> class calls the <code>SpecificOperation()<\/code> method of the <code>Adaptee<\/code> object.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Object Adapter example<\/h3>\n\n\n\n<p>Suppose you need to implement a payment feature in your system application. And you have to use a third-party class called <code>PaymentProcessor<\/code>.<\/p>\n\n\n\n<p>The <code>PaymentProcessor<\/code> class has a method called <code>ProcessPayment<\/code>, which accepts a <code>decimal<\/code> argument that represents the payment amount:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">PaymentProcessor<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">ProcessPayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>\n    {\n        Console.WriteLine(<span class=\"hljs-string\">$\"You have paid <span class=\"hljs-subst\">{amount:C}<\/span>.\"<\/span>);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>But your application uses an interface called <code>IPaymentProvider<\/code> with a method <code><code>MakePayment<\/code><\/code>. The problem is that the <code><code>MakePayment<\/code><\/code> method accepts two arguments: a string that represents the payment details and a decimal value that represents the payment amount:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">IPaymentProvider<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">MakePayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> details, <span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>As you can see, the interface that your application expects is <code>IPaymentProvider<\/code> which is incompatible with the class <code>PaymentProcessor<\/code>.<\/p>\n\n\n\n<p>To solve this problem, you can apply the object Adapter pattern. <\/p>\n\n\n\n<p>To use the <code>PaymentProcessor<\/code> with your <code>IPaymentProvider<\/code> interface, you can create an <code>Adapter<\/code> class called <code>PaymentProviderAdapter<\/code>. <\/p>\n\n\n\n<p>The <code>PaymentProviderAdapter<\/code> needs to implement the <code>IPaymentProvider<\/code> interface and wrap the <code><code>PaymentProcessor<\/code><\/code> class. Also, the <code>MakePayment<\/code> method of the <code>PaymnetProviderAdapter<\/code> needs to translate the call to the <code>ProcessPayment<\/code> method of the <code><code>PaymentProcessor<\/code><\/code> class:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-comment\">\/\/ The adapter class that adapts the PaymentProcessor<\/span>\n<span class=\"hljs-comment\">\/\/ to the IPaymentProvider interface<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">PaymentProviderAdapter<\/span> : <span class=\"hljs-title\">IPaymentProvider<\/span>\n{\n    <span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-keyword\">readonly<\/span> PaymentProcessor _paymentProcessor;\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-title\">PaymentProviderAdapter<\/span>(<span class=\"hljs-params\">PaymentProcessor paymentProcessor<\/span>)<\/span>\n    {\n        _paymentProcessor = paymentProcessor;\n    }\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">MakePayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> details, <span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>\n    {\n        Console.WriteLine(<span class=\"hljs-string\">$\"Making a payment for: <span class=\"hljs-subst\">{details}<\/span>\"<\/span>);\n        _paymentProcessor.ProcessPayment(amount);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Now, you can use the <code>PaymentProcessor<\/code> class in your application as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Program<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Main<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span>&#91;] args<\/span>)<\/span>\n    {\n        <span class=\"hljs-keyword\">var<\/span> paymentProcessor = <span class=\"hljs-keyword\">new<\/span> PaymentProcessor();\n        <span class=\"hljs-keyword\">var<\/span> paymentProvider = <span class=\"hljs-keyword\">new<\/span> PaymentProviderAdapter(paymentProcessor);\n\n        paymentProvider.MakePayment(<span class=\"hljs-string\">\"C# design pattern course\"<\/span>, <span class=\"hljs-number\">100.0<\/span>m);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In the <code>Program<\/code> class:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, create an instance of the <code><code>PaymentProcess<\/code><\/code> class and create an instance of the <code>PaymentProviderAdapter<\/code> class that wraps the <code><code>PaymentProcess<\/code><\/code>&#8216;s object. <\/li>\n\n\n\n<li>Second, call the <code>MakePayment<\/code> of the instance of the <code>PaymentProviderAdapter<\/code> class to make a payment, which will in turn call the <code>ProcessPayment<\/code> method on the <code>PaymentProcessor<\/code> class.<\/li>\n<\/ul>\n\n\n\n<p>Put it all together.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">ObjectAdapter<\/span>;\n\n<span class=\"hljs-comment\">\/\/ The third-party PaymentProcessor class<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">PaymentProcessor<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">ProcessPayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>\n    {\n        Console.WriteLine(<span class=\"hljs-string\">$\"You have paid <span class=\"hljs-subst\">{amount:C}<\/span>.\"<\/span>);\n    }\n}\n\n<span class=\"hljs-comment\">\/\/ your application's IPaymentProvider interface<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">IPaymentProvider<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">MakePayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> details, <span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>;\n}\n\n<span class=\"hljs-comment\">\/\/ The adapter class that adapts the PaymentProcessor<\/span>\n<span class=\"hljs-comment\">\/\/ to the IPaymentProvider interface<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">PaymentProviderAdapter<\/span> : <span class=\"hljs-title\">IPaymentProvider<\/span>\n{\n    <span class=\"hljs-keyword\">private<\/span> <span class=\"hljs-keyword\">readonly<\/span> PaymentProcessor _paymentProcessor;\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-title\">PaymentProviderAdapter<\/span>(<span class=\"hljs-params\">PaymentProcessor paymentProcessor<\/span>)<\/span>\n    {\n        _paymentProcessor = paymentProcessor;\n    }\n\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">MakePayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> details, <span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>\n    {\n        Console.WriteLine(<span class=\"hljs-string\">$\"Making a payment for: <span class=\"hljs-subst\">{details}<\/span>\"<\/span>);\n        _paymentProcessor.ProcessPayment(amount);\n    }\n}\n\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Program<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Main<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span>&#91;] args<\/span>)<\/span>\n    {\n        <span class=\"hljs-keyword\">var<\/span> paymentProcessor = <span class=\"hljs-keyword\">new<\/span> PaymentProcessor();\n        <span class=\"hljs-keyword\">var<\/span> paymentProvider = <span class=\"hljs-keyword\">new<\/span> PaymentProviderAdapter(paymentProcessor);\n\n        paymentProvider.MakePayment(<span class=\"hljs-string\">\"C# design pattern course\"<\/span>, <span class=\"hljs-number\">100.0<\/span>m);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\">Making a payment <span class=\"hljs-keyword\">for<\/span>: C<span class=\"hljs-meta\"># design pattern course<\/span>\nYou have paid $<span class=\"hljs-number\">100.00<\/span>.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Class Adapter pattern<\/h2>\n\n\n\n<p>The Object Adapter pattern uses composition to wrap the incompatible class. Meanwhile, the class Adapter pattern uses <a href=\"https:\/\/csharptutorial.net\/csharp-tutorial\/csharp-inheritance\/\">inheritance<\/a>.<\/p>\n\n\n\n<p>In the Class Adapter pattern, the <code>Adapter<\/code> class extends both the <code>Adaptee<\/code> and target classes. The <code>Adapter<\/code> class then overrides the method of the target class and calls the corresponding method of the <code>Adaptee<\/code> interface.<\/p>\n\n\n\n<p>C# doesn&#8217;t support multiple inheritances that allow a class to extend two or more classes. But, a class can extend a class and implement multiple interfaces.<\/p>\n\n\n\n<p>The following UML diagram illustrates the Class Adapter pattern:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/csharptutorial.net\/wp-content\/uploads\/2023\/04\/CSharp-Class-Adapter-Pattern.svg\" alt=\"\" class=\"wp-image-1577\"\/><\/figure>\n\n\n\n<p>In this diagram, the <code>Adapter<\/code> class inherits from the <code>Adaptee<\/code> class instead of composing it. And the <code>Operation()<\/code> method of the <code>Adapter<\/code> class calls the <code>SpecificOperation()<\/code> method of the <code>Adaptee<\/code> class.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Class Adapter example<\/h3>\n\n\n\n<p>The following is the same as the example that uses the object adapter pattern, but uses the Class Adapter pattern instead:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"C#\" data-shcb-language-slug=\"cs\"><span><code class=\"hljs language-cs\"><span class=\"hljs-keyword\">namespace<\/span> <span class=\"hljs-title\">ClassAdapter<\/span>;\n\n<span class=\"hljs-comment\">\/\/ The third-party PaymentProcessor class<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">PaymentProcessor<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">ProcessPayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>\n    {\n        Console.WriteLine(<span class=\"hljs-string\">$\"You have paid <span class=\"hljs-subst\">{amount:C}<\/span>.\"<\/span>);\n    }\n}\n\n<span class=\"hljs-comment\">\/\/ Our application's IPaymentProvider interface<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">interface<\/span> <span class=\"hljs-title\">IPaymentProvider<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">MakePayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> details, <span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>;\n}\n\n<span class=\"hljs-comment\">\/\/ The adapter class that adapts the PaymentProcessor to the IPaymentProvider interface<\/span>\n<span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">PaymentProviderAdapter<\/span> : <span class=\"hljs-title\">PaymentProcessor<\/span>, <span class=\"hljs-title\">IPaymentProvider<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">MakePayment<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span> details, <span class=\"hljs-keyword\">decimal<\/span> amount<\/span>)<\/span>\n    {\n        Console.WriteLine(<span class=\"hljs-string\">$\"Making a payment for: <span class=\"hljs-subst\">{details}<\/span>\"<\/span>);\n        ProcessPayment(amount);\n    }\n}\n\n<span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Program<\/span>\n{\n    <span class=\"hljs-function\"><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">static<\/span> <span class=\"hljs-keyword\">void<\/span> <span class=\"hljs-title\">Main<\/span>(<span class=\"hljs-params\"><span class=\"hljs-keyword\">string<\/span>&#91;] args<\/span>)<\/span>\n    {\n        <span class=\"hljs-keyword\">var<\/span> paymentProvider = <span class=\"hljs-keyword\">new<\/span> PaymentProviderAdapter();\n\n        paymentProvider.MakePayment(<span class=\"hljs-string\">\"C# design pattern course\"<\/span>, <span class=\"hljs-number\">100.0<\/span>m);\n    }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">C#<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">cs<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The Adapter pattern allows the objects with incompatible interfaces to work together.<\/li>\n\n\n\n<li>The Object Adapter pattern uses the composition while the Class Adapter class uses inheritance.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful ?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"1572\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-design-patterns\/csharp-adapter-pattern\/\"\n\t\t\t\tdata-post-title=\"C# Adapter Pattern\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"1572\"\n\t\t\t\tdata-post-url=\"https:\/\/www.csharptutorial.net\/csharp-design-patterns\/csharp-adapter-pattern\/\"\n\t\t\t\tdata-post-title=\"C# Adapter Pattern\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to use the C# Adapter pattern to enable classes of incompatible interfaces to work together.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1441,"menu_order":21,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1572","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/comments?post=1572"}],"version-history":[{"count":5,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1572\/revisions"}],"predecessor-version":[{"id":1819,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1572\/revisions\/1819"}],"up":[{"embeddable":true,"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/pages\/1441"}],"wp:attachment":[{"href":"https:\/\/www.csharptutorial.net\/wp-json\/wp\/v2\/media?parent=1572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}