LINQPad for everything(or at least a lot)

A lot of programming languages have great REPL’s. Some take great pride in them, while others barely mention them and almost hide them. One of those languages is definitely C#.
How is it otherwise possible that I have been programming in C# for several…


This content originally appeared on DEV Community and was authored by Stipe

A lot of programming languages have great REPL's. Some take great pride in them, while others barely mention them and almost hide them. One of those languages is definitely C#.
How is it otherwise possible that I have been programming in C# for several years without coming in contact with it's REPL....the LINQPad?!

I blame the blogs and tutorials, of course. Of all the countless hours I spent learning and watching people code, not single one of them has used LINQPad to showcase a piece of code, an algorithm or an idea. And why is that? Why do we have to use a new console application just to explain how records are used? Or why are we introduced in an already existing web app just to demonstrate connecting to database? It can all be done from LINQPad. And more...But let us start from the beginning, the REPL.

REPL

REPL stands for Read-Eval-Print Loop. It is basically a simple or barebone programming environment, that is capable of taking a user's input, executing and evaluating the result and displaying it back to the user. Then press repeat and the loop part is also covered.
Why would you need or want to use a REPL? Well, for everything actually. There are so many usecases that I will not cover them here but I will make separate posts about all the stuff you can and should be doing in a REPL. For now, just stick with me.

LINQPad

LINQPad is the creation of Joseph Albahari. It allows us to quickly and hassle free write C# code, prototype and experiment, query databases and much more all from the same window. LINQPad has both a free and a paid version. There are other REPL's for C# that are completely free such as RoslynPad, but once you start using it on a daily basis upgrading to a paid licence is worth considering.

LINQPad can download nugets, import namespaces and dlls and do debugging, making it as powerful as a full fledged mini IDE. It can completely replace PowerShell if you are willing to create your own scripts and code snippets, it can replace SQL Studio when you don't want to wait for it to open, and I would even go so far as to say that LINQPad has promissing usecases in penetration testing.

Imagine an interactive environment where you can write code, inspect the results, rewrite it then run again, chain the functions, display results and reuse the code at any time later on. If you invest some time and write reconnaissance scripts you can completely replace nmap with a single function call and learn how it all works along the way. Next time you want to scan a 1000 ports, no need to open terminal, you do it form LINQPad and you can even format the results to your liking. The options are endless...Or almost endless - the LINQPad's main flaw is that it is not cross platform. What a shame, especially for red teamers.

LinqPad window

Educational tool

Above everything else, LINQPad is made for learning and playing with C#. When was the last time you picked a random System class and just tried out some functions? Or tried to model some system using DDD or functional programming? Ah yes, but you need to open an IDE and fire up the good old console, then delete the Console.WriteLine....! Well, no more. Just open a linqpad scratch file and start coding, who knows what you might come up with and discover - that is the joy of programming all of us want, to program out of curiosity, not necessity.

What about you, are you using LINQPad or RoslynPad, maybe C# notebooks? or do you find all of this not really necessary? I would love to hear your thoughts on this, so do leave a comment.

One last thing, the best command ever.... .Dump();
It just prints whatewer stuff you throw at it to the output window, no need to worry about string, int, object or entire winforms app, it gets printed!

There is so much that can be added in regards to REPL's, LINQPad and writing fast and simple code just for fun. I hope you will at least give it a shot, because in programming we like to keep it simple stup...

LinqPad Dump command


This content originally appeared on DEV Community and was authored by Stipe


Print Share Comment Cite Upload Translate Updates
APA

Stipe | Sciencx (2024-08-30T20:39:40+00:00) LINQPad for everything(or at least a lot). Retrieved from https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/

MLA
" » LINQPad for everything(or at least a lot)." Stipe | Sciencx - Friday August 30, 2024, https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/
HARVARD
Stipe | Sciencx Friday August 30, 2024 » LINQPad for everything(or at least a lot)., viewed ,<https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/>
VANCOUVER
Stipe | Sciencx - » LINQPad for everything(or at least a lot). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/
CHICAGO
" » LINQPad for everything(or at least a lot)." Stipe | Sciencx - Accessed . https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/
IEEE
" » LINQPad for everything(or at least a lot)." Stipe | Sciencx [Online]. Available: https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/. [Accessed: ]
rf:citation
» LINQPad for everything(or at least a lot) | Stipe | Sciencx | https://www.scien.cx/2024/08/30/linqpad-for-everythingor-at-least-a-lot/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.