StringBuilder.ToString() vs Reflection

I had an intriguing conversation with a friend on Friday about the performance of using the StringBuilder.ToString() method to return the value of the String contained in the StringBuilder object.  Following this conversation, I decided to take a deeper look at how StringBuilder works.  Here is the StringBuilder.ToString() method code from Reflector: public override string…

6

Parallel Computing in .NET

A recent article in MSDN magazine talks about the upcoming CTP release of the Parallel FX library, currently scheduled for the Fall of 2007. You can find the article here: Optimize Managed Code for Mulit-Core Machines. The recent trend with CPUs has been a multi-core approach rather than focusing on speed increases.  This is great,…

0

Mixing Extension Methods and Anonymous Types

In my recent post Overcoming the Limitations of Anonymous Types, I talked about ways to get around the method scope and read-only limitations of anonymous types.  These were fairly simple examples that used reflection to gather data from the type once it had been passed outside of the containing method.  You could see the properties…

0

Replacing CMD with PowerShell

First off, I really like Windows PowerShell.  I have been using it for a while now and I find it extremely powerful.  I now use it for every command line thing that I do.  (I would also recommend the PowerShell Community Extensions.  These add some very useful features to PS.  One that I particularly enjoy…

7

Overcoming the Limitations of Anonymous Types

It seems clear that the new anonymous types feature for C# 3.0 is going to be very useful, however there are a few limitations that come along with them: limited scope and read-only properties. Anonymous types have a method scope.  This means that if you pass an anonymous type outside the containing method boundary, then…

1

LINQ Makes Life Easier

LINQ is really cool.  There are tons of examples on the web that show you how to use LINQ to query a database, xml file, text file or collection.  This is what LINQ will primarily be used for; to simplify and support the need to provide an association between external relational data and object oriented…

1

Simple GZip compression of files with .NET

I had to do some file compression recently (which oddly enough I had never had to do before).   Compressing files using GZipStream in a few lines of code: using (FileStream fStream = new FileStream(@”C:\test.docx.gzip”, FileMode.Create, FileAccess.Write)){ using (GZipStream zipStream = new GZipStream(fStream, CompressionMode.Compress)) { byte[] inputfile = File.ReadAllBytes(@”c:\test.docx”); zipStream.Write(inputfile, 0, inputfile.Length); }} Decompressing is also…

3

Process Explorer v11.0 Released

A new version of Process Explorer was released today! If you do not already have it, I highly suggest that you download it and use it.  It is an amazing tool, basically Task Manager on steroids.  You can find just about every conceivable bit of information about any process running on your computer.  This is…

1

C# 3.0 Anonymous Types

I have been playing around with some of the new C# 3.0 features, and I really have to say that I like the anonymous types. In reality, they do not present a great advantage over typical code defined classes, but they are simple and easy to use and require a lot less code. I really…

1

A Class Every Developer Should Take

Last week I attended the Wintellect course entitled Mastering .NET Debugging taught by debugging guru John Robbins. It was a 2-day virtual classroom that utilized Live Meeting. The course was very good and I would highly recommend it to all Windows developers. John teaches both the art of debugging and how to write better code…

0