Roy
Roy

Reputation: 2323

How to declare variables and use statements in LINQPad?

Do you know how to declare variables in LINQPad in order to hold the query result and use it later in multiply queries?

Thanks!

Upvotes: 22

Views: 12691

Answers (1)

Christian C. Salvadó
Christian C. Salvadó

Reputation: 827862

Just select C# or VB Statements, and you will be able to write variable declarations.

To view the content of your variables, you can use the Dump extension method available on all types:

var test = "Test String";
test.Dump(); // the content is shown in the output

Or you can use the Console.Write method.

linqpad

If you want to include method or class declarations within a LinqPad file, select C# or VB Program.

Upvotes: 50

Related Questions