{"id":4019,"date":"2014-03-30T07:13:06","date_gmt":"2014-03-30T07:13:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/passing-an-interface-to-a-base-class-c-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:13:06","modified_gmt":"2014-03-30T07:13:06","slug":"passing-an-interface-to-a-base-class-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/passing-an-interface-to-a-base-class-c-collection-of-common-programming-errors\/","title":{"rendered":"Passing an interface to a base class &#8211; C#-Collection of common programming errors"},"content":{"rendered":"<p>What exactly do you mean by sending an interface?<\/p>\n<p>If you want to pass the type statically, you can use a generic (i.e. templated) method:<\/p>\n<pre><code>public void SendName(T properties)\n    where T : IProperties    \/\/ types passed in must derive from IProperties\n{\n    var name = properties.Name;\n    \/\/ ...\n}\n\n\/\/...\n\n\/\/ Usage:\nbase.SendName(this);\n<\/code><\/pre>\n<p>If you want to send the type at runtime, you can pass around Type objects:<\/p>\n<pre><code>public void SendName(Type type)\n{ \/* Do stuff *\/ }\n\n\/\/...\n\n\/\/ Usage:\nbase.SendName(typeof(IProperties));\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What exactly do you mean by sending an interface? If you want to pass the type statically, you can use a generic (i.e. templated) method: public void SendName(T properties) where T : IProperties \/\/ types passed in must derive from IProperties { var name = properties.Name; \/\/ &#8230; } \/\/&#8230; \/\/ Usage: base.SendName(this); If you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4019","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4019"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4019\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}