Pesquisar este blog

domingo, 29 de agosto de 2010

Determine the number of lines within a text file

First option: 
var lineCount = File.ReadAllLines(@"C:\file.txt").Length;
 
Second option: 
var lineCount = 0;
using (var reader = File.OpenText(@"C:\file.txt"))
{
    while (reader.ReadLine() != null)
    {
        lineCount++;
    }
}

The first one loads the entire contents of the file into an array which
means it must allocate at least as much memory as the size of the file.
The second merely loops one line at a time so it never has to allocate
more than one line's worth of memory at a time.

ReSharper

http://www.jetbrains.com/resharper/

How ReSharper Helps Visual Studio Users

  • Continuous code quality analysis in C#, XAML, XML, ASP.NET, and ASP.NET MVC.
  • Instant fixes to eliminate errors and code smells.
  • 40 solution-wide refactorings to safely change your code base, and 200+ code editing helpers.
  • Extended web development support with code inspections, code generation, navigation, and extended IntelliSense.
  • Navigation features to let you instantly traverse your whole solution.

segunda-feira, 16 de agosto de 2010

Nokia N900