I like LINQPad for prototyping C# applications and trying out short snippets. In many scenarios, I have to see the output of what I’m trying out. I used to treat my snippets as small console applications, and I used to use Console.WriteLine() statements to display the output.

Not anymore! In a tech video on YouTube, I saw this option and loved it:

In LINQPad, there’s a generic extension method called Dump(). It writes the output to the console. Exactly as Console.WriteLine but in a much more concise way.

For example:

var nums = new[] { 1, 2, 3, 4, 5, 6 };
var sum = nums.Aggregate((a,b) => a + b);
Console.WriteLine(sum);

The code block above displays 21, and it can be shortened with the Dump method

var nums = new[] { 1, 2, 3, 4, 5, 6 };
nums.Aggregate((a,b) => a + b).Dump();

It shows the same result but in a shorter way.

Resources


Volkan Paksoy

Volkan Paksoy is a software developer with more than 15 years of experience, focusing mostly on C# and AWS. He’s a home lab and self-hosting fan who loves to spend his personal time developing hobby projects with Raspberry Pi, Arduino, LEGO and everything in-between.