LINQPad is a helpful tool for testing and learning LINQ snippets. Although it supports all LINQ in C# 4.0 and Framework 4.0, it does have a querky syntax that you must implement in order to add your own classes and/or methods.
In short, to add your own classes and/or methods to LINQPad, you must:
- Create a New Query and choose “C# Statement(s)” for the LINQPad Language
- Position all of your LINQPad scripts at the top of the page
- After the very last LINQPad script, add a closing curly brace “}”
- After the closing curly brace that you added in step #3, you can add your classes and or methods as you would normally.
- When you finish writing all of your classes and/or methods, omit the very last closing curly brace. – Strange, but true.
Here’s an example LINQPad query that includes a Method and two Classes. Notice how the LINQPad query is positioned at the top of the page with an appended closing curly brace. Next, notice how the very last class (Pet) has omitted its closing curly brace.