{"id":11577,"date":"2023-10-30T11:29:05","date_gmt":"2023-10-30T02:29:05","guid":{"rendered":"http:\/\/www.tyosuke20xx.com\/blog\/?p=11577"},"modified":"2023-10-30T11:29:07","modified_gmt":"2023-10-30T02:29:07","slug":"c-interface","status":"publish","type":"post","link":"http:\/\/www.tyosuke20xx.com\/blog\/?p=11577","title":{"rendered":"C# interface"},"content":{"rendered":"\n<p>interface IPoint<br>{<br>int Px<br>{<br>get; set;<br>}<br>int Py<br>{<br>get; set;<br>}<br>}<\/p>\n\n\n\n<p>class ReversePoint : IPoint<br>{<br>int x;<br>int y;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public ReversePoint(int x, int y)\n{\n    this.x = x;\n    this.y = y;\n}\n\npublic int Px\n{\n    get { return -x; }\n    set { x = value; }\n}\n\n\/\/ Implementing Py similarly to Px\npublic int Py\n{\n    get { return -y; } \/\/ Return the negative of y\n    set { y = value; } \/\/ Set y directly\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n\n\n\n<p>class MainClass<br>{<br>public static void DisplayPoint( IPoint point)<br>{<br>Console.WriteLine(&#8220;x={0},y={1}&#8221;, point.Px, point.Py);<br>}<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>static void Main()\n{\n    ReversePoint p1 = new ReversePoint(-12, -300);\n\n    Console.WriteLine(p1.Px);\n    Console.WriteLine(p1.Py);\n\n    ReversePoint p2 = new ReversePoint(12, 300);\n\n    \/\/\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u53c2\u7167\n    DisplayPoint(p2);\n}<\/code><\/pre>\n\n\n\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>interface IPoint{int Px{get; set;}int Py{get; set;}} class ReversePoint : IPoint{int x;int y; } class MainClas &hellip; <a href=\"http:\/\/www.tyosuke20xx.com\/blog\/?p=11577\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;C# interface&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[33,4],"tags":[35,3],"class_list":["post-11577","post","type-post","status-publish","format-standard","hentry","category-c","category-programming","tag-c","tag-programming"],"aioseo_notices":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11577","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11577"}],"version-history":[{"count":1,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11577\/revisions"}],"predecessor-version":[{"id":11578,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11577\/revisions\/11578"}],"wp:attachment":[{"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11577"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11577"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tyosuke20xx.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11577"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}