{"id":141,"date":"2012-05-18T21:16:42","date_gmt":"2012-05-18T19:16:42","guid":{"rendered":"http:\/\/jcoder.me\/blog\/?p=141"},"modified":"2012-05-18T21:16:42","modified_gmt":"2012-05-18T19:16:42","slug":"c-extension-methods-part-3","status":"publish","type":"post","link":"https:\/\/jcoder.me\/blog\/2012\/05\/18\/c-extension-methods-part-3\/","title":{"rendered":"C# Extension Methods, Part 3"},"content":{"rendered":"<p>While I&#8217;ll probably (have to) focus on Java for the next month, I just came up with the idea of just another extension method class. It is acually not very helpful but it again shows how powerful extension methods can be.<\/p>\n<p>This is how it can be used:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nStringBuilder buffer = new StringBuilder();\r\nforeach (int i in 10.To(15))\r\n{\r\n    buffer.AppendLine(&quot;&quot; + i);\r\n}\r\n<\/pre>\n<p>I know that this piece of code does not look very helpful, because the same can easily be done using a simple for loop, but there might be some cases &#8211; especially when using LINQ &#8211; when it is quite useful to have an iterable range of int values.<\/p>\n<p>The code is up on my\u00a0<a title=\"my C# extension project on github\" href=\"https:\/\/github.com\/jcoder\/jCsharpExtensions\" target=\"_blank\">github C# extension method project<\/a>. Feel free to use or fork it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While I&#8217;ll probably (have to) focus on Java for the next month, I just came up with the idea of just another extension method class. It is acually not very helpful but it again shows how powerful extension methods can &hellip; <a href=\"https:\/\/jcoder.me\/blog\/2012\/05\/18\/c-extension-methods-part-3\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,1,28,11],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-coding","category-common","category-extension-methods","category-project"],"_links":{"self":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":5,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":235,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions\/235"}],"wp:attachment":[{"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jcoder.me\/blog\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}