﻿{"id":72,"date":"2013-06-24T18:44:20","date_gmt":"2013-06-24T16:44:20","guid":{"rendered":"http:\/\/blog.pjsen.eu\/?p=72"},"modified":"2022-02-22T13:46:11","modified_gmt":"2022-02-22T12:46:11","slug":"interface-type-parameter-covariance-and-contravariance-in-c","status":"publish","type":"post","link":"https:\/\/blog.pjsen.eu\/?p=72","title":{"rendered":"Interface type parameter covariance and contravariance in C#"},"content":{"rendered":"<ul>\n<li>I would like this blog post to serve as a quick reference that recalls the basic concept of covariant and contravariant type parameters of generic interfaces in the C# language.<\/li>\n<li>I tried to keep the example as simple as possible. Included comments explain the key points. No long stories and no dissertations.<\/li>\n<li>The code does nothing, but compiles on C# 4.0 or newer compiler.<\/li>\n<li>Try deleting the first slash character in the first line to kind of switch between the snippets (BTW this is cool trick \ud83d\ude42 ).<\/li>\n<\/ul>\n<p><script src=\"https:\/\/gist.github.com\/przemsen\/97eaf5028e91b9111fae417055eb9c3e.js?file=blog-2013-06-24-cs1.cs\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I would like this blog post to serve as a quick reference that recalls the basic concept of covariant and contravariant type parameters of generic interfaces in the C# language. I tried to keep the example as simple as possible. Included comments explain the key points. No long stories and no dissertations. The code does<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[10],"class_list":["post-72","post","type-post","status-publish","format-standard","hentry","category-quick-tip","tag-c"],"_links":{"self":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/posts\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=72"}],"version-history":[{"count":0,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.pjsen.eu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}