After my blog post yesterday on File.ReadAllLines() vs StreamReader I have been thinking that more code does not necessarily mean more, or does it? I mean syntactically the first one is a one liner and the second one is a few lines, but I do feel that the latter adds more value. Why? Well firstly because streams seem to be an important part and concept in the .NET framework and secondly the streamreader class seems to dispose of resources a bit better. It also seems as if my implementation of the streamreader class deals with something the first option has still to deal with. I mean you have to assign a string array and then somewhere you have to iterate through the content of the array, whereas with the streamreader you can do all of that once. Looping through the contents that gets read by the streamreader class instance can be achieved by either appending the results to a stringbuilder instance or by using a function that implements the IEnumerable interface and uses the yield keyword. Using a function that implements IEnumerable means that you can run a foreach against it. I do honestly find this approach a lot more expressive. Its also interesting to note that the streamreader class performs better in some cases.
Pages
Archives
- November 2011 (5)
- August 2011 (1)
- July 2011 (1)
- June 2011 (3)
- May 2011 (1)
- April 2011 (11)
- March 2011 (3)
- February 2011 (5)
- January 2011 (6)
- December 2010 (2)
- November 2010 (3)
- October 2010 (2)
- September 2010 (5)
- August 2010 (4)
- July 2010 (3)
- June 2010 (7)
- May 2010 (1)
- April 2010 (6)
- March 2010 (2)
- February 2010 (1)
- January 2010 (1)
- December 2009 (2)
- November 2009 (5)
- October 2009 (26)
- September 2009 (15)
- August 2009 (2)
- July 2009 (3)
- June 2009 (1)
- May 2009 (1)
- April 2009 (3)
- March 2009 (2)
- February 2009 (3)
- January 2009 (11)
- December 2008 (13)
- November 2008 (8)
- October 2008 (10)
- September 2008 (9)
- August 2008 (13)
- July 2008 (12)
- June 2008 (9)
- May 2008 (8)
- April 2008 (6)
Categories
- 2011 (1)
- AJAX (14)
- Application Development (23)
- ASP.NET (28)
- ASP.NET MVC (8)
- Bing (1)
- Blog Action Day (1)
- Browsers (5)
- C# (62)
- Chrome (1)
- Content Management Systems (1)
- Design Patterns (1)
- DevDays (1)
- eMarketing (6)
- Facebook (4)
- Firefox (3)
- Fremus.co.za (8)
- General (48)
- Google Chrome (1)
- Information Technology (1)
- Internet Explorer (2)
- jQuery (4)
- Leadership (2)
- LINQ to XML (4)
- Microsoft (1)
- Microsoft Events (1)
- Music (1)
- News (2)
- PC Hardware (1)
- Personal (16)
- Photography (1)
- SEO (3)
- Silverlight (11)
- Software (1)
- Springboks (1)
- SQL Server 2005 (7)
- SQL Server 2008 (3)
- tech (2)
- TranceFamily (1)
- TV Series (1)
- Twitter (1)
- WCF (1)
- Web 2.0 (13)
- Web Design (9)
- Web Development (36)
- Web Search (1)
- Web Technologies (39)
- Windows Phone 7 (2)
- Windows Powershell 2.0 (1)
- Wordpress (6)
- WPF (2)
Tags
.NET Adobe Flash AJAX Armin van Buuren ASP.NET ASP.NET MVC C# concept context CSS e-Marketing Facebook Firefox 3 Fremus General Thoughts GMail Google Google Analytics Javascript jquery LINQ to XML LiveValidation Microsoft Microsoft Access Microsoft Powerpoint object-oriented Personal PHP Programming ScrewTurn wiki Silverlight Social Media Social Networking South African E-Marketing SQL Server 2005 Twitter Visual Studio 2008 WCF web-based solutions Web 2.0 Web Design web development wiki's Wordpress WPF
© Fremus.co.za 2009 | Created by Jay Hafling.
Powered by WordPress
Place your comment