Capture console output in C#

The following C# source code demonstrates how to capture the output of a console program: