Home > dotnet 4 > LinqPad


I know you guys have already heard a lot about LinqPad and how great it is. If not here is a blog about LinqPad and it’s a great tool for learning LINQ.

But one of the cool things about LinqPad is that it is a great code snippet IDE too , with LinqPad you will never ever have a need to write a Console Application for a quick prototype.

Today I am going to show how to use external assembly or custom assemblies to use in this code snippet IDE. For illustration sake I’m going to use the JavascriptSerializer class to see whether my dotnet class will get serialize or not as a JSON Object and if it serializes then how would my JSON object will look like

So let’s assume you have downloaded and install LinqPad successfully. In order to add an external assembly click Query > Query Properties > Additional References.

Linq Pad Query Properties

Click on “Add” to add a new assembly.

Adding a new Assembly

You can type in the assembly you want to add and Autocompletion will take care of it.

Select Assembly

Import any additional namespace you might have with in the selected assembly. Like in my case I am importing the System.Web.Script.Serialization namespace.

Namespace import

Lets write some code…

Code block

This is one gotchas I want to highlight when you first start using LinqPad. When you hit the run button you see it says “Error compling query” and it took me a while to figure it out. It’s complaining becasue in LinqPad by default it assumes you are trying to execute some expression so lets change it to “C# program”.

C# Expression option

Now when we run the program it shows the desired result.

JSON Object

  1. Gorang
    August 16, 2010 at 12:36 pm

    Nice one. I have used it before and it’s handy to check the syntax or to get the complex logic right.

  2. Giles
    August 19, 2014 at 8:15 pm

    Thanks so much for including the screenshots! I had no idea how to get the ‘using’ statements (even after seeing somebody else’s explanation) and this made it real simple.

  1. August 29, 2013 at 8:07 am

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: