Snippet Compiler is great for this.
LINQPad is also good for testing LINQ code.
EDIT
I guess this is the time when I mention that Snippet Compiler has not been updated for more than five years and therefore is no longer the best option.
However, I first abandoned LINQPad. As Dean noted in the comments, LINQPad is great for all kinds of code, not just LINQ queries. In fact, it has become an indispensable tool for me. I use it daily, not only for quick testing of short fragments, but for relatively complex mini-programs. Its advanced output formatting allows you to very quickly learn intermediate and final results.
P Daddy Dec 21 '08 at 18:15 2008-12-21 18:15
source share