LINQPad – Where have you been all my life?

Posted: February 18, 2015 in C#, CoolStuff, Programming, Tools

This weekend I watched the rather excellent video series called Message Queue Fundamentals in .NET on Pluralsight. Elton (the author of the video) uses LINQPad to demonstrate concepts and code throughout the video lessons. Up to this point I had never even heard of it  – but I was impressed!

“But what does it do!?” I hear you shout. It is a lightweight application where you can write C#/VB/F# statements (or console application-esque programs) and execute them within the application. This doesn’t sound that great but it’s actually very powerful and cool.

It comes with built in support for referencing the .NET Base Class Libraries (BCL) – just hit F4 to add a reference. Naturally you can also add references to any dll that you like also. This makes an excellent tool for “trying something out” without the pain of creating a new console application.

Like SQL Server Management Studio you can highlight code you want to execute, hit play and it will only execute the highlighted code. You can use the Dump() extension method to output any object to the output.

You can also read input from user like you can a console application. At some point I am sure I will find some great use for this…what that is I don’t know!!


You can even execute multiple programs at once – in the video tutorial Elton has multiple applications sending and listening for messages simultaneously.

Think about it – you no longer need to create a console application just to try out a bit of code – or to write that adhoc program to <insert some menial task> that will go in the bin shortly after. You can easily organise and save any code you write too!

Okay, so if that hasn’t whet your appetite then maybe this will…you can use LINQ to SQL to query your database! LINQPad have even layed down the gauntlet with the LINQPad challenge where they are encouraging you to replace SQL Server Management studio…a challenge that I have accepted!


How much does it cost? Well it’s free with 1 tiny, little, small, incey-wincey drawback…the free version doesn’t come with intellisense. I am (perhaps overly) excited by this and have (literally) just purchased a license.


By no means is LINQPad going to replace Visual Studio – it’s not even trying too, but it may be useful for the times where you just want to write some code. I am also sold on the ability to query a database with LINQ, and with support for SQL for those unfortunate times where you have no choice I probably will use SSMS less often.

Here is simple code example showing user input.

 // Simple interactive app
void Main()
	var user = new
		Name = ScreenHelper.GetUsersName(),
		Age = ScreenHelper.GetUserAge()


public static class ScreenHelper
	public static string GetUsersName()
		Console.WriteLine("What is your name?");
		return Console.ReadLine();

	public static int GetUserAge()
		while (true)
			Console.WriteLine("What is your age?");
			var input = Console.ReadLine();

			int age;
			if (int.TryParse(input, out age))
				return age;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s