jCoder's Blog
C# Extension Methods, Part 3
While I’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.
This is how it can be used:
StringBuilder buffer = new StringBuilder(); foreach (int i in 10.To(15)) { buffer.AppendLine("" + i); }
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 – especially when using LINQ – when it is quite useful to have an iterable range of int values.
The code is up on my github C# extension method project. Feel free to use or fork it.
Search
Categories
Tags
Arduino ATtiny blinking C# Code-Download Coding Converter email FEZ first steps GPIO Hardware ID12 James Java JSP jspinfo LCD LED Lights Linux microcontroller Netduino NETMF Network NewBase60 opensource Panda II PWM Python Raspberry Pi RFID RGB screen server shell slow motion Traffic Light video WS2812Blogroll
Archives
- December 2014 (1)
- January 2014 (1)
- March 2013 (1)
- December 2012 (1)
- October 2012 (2)
- September 2012 (3)
- June 2012 (3)
- May 2012 (1)
- April 2012 (3)
- March 2012 (1)
- February 2012 (1)
- December 2011 (1)
- November 2011 (1)
- October 2011 (1)
- September 2011 (1)
- August 2011 (2)
- July 2011 (3)
- June 2011 (3)