简体   繁体   中英

Any way to do quick one-off compilations from within Visual Studio without the need to create an entirely new Proj/Solution?

Is there any Visual Studio tool that let's you run C# code without having to compile an entire project or create a new project/solution just to test that bit of code?

The problem I often run into is that sometimes I'll be curious "How does this code work in this context?" and I don't really feel like creating a new project/solution just to test that bit of code. Is there any tool out there (bonus if it can be integrated into Visual Studio) that let's me quickly compile a tiny piece of code and run just that piece of code?

I remember in the past LINQPad would let me run LINQ queries without the need to create an entirely new project/solution.

Well, there's LINQPad as you've mentioned. You can use that for more than just queries - you can write fairly arbitrary bits of C# in it.

I have Snippy which I really wrote for C# in Depth, so that I could present snippets like this:

int x = 10;
Console.WriteLine(x);

and compile and run those with nothing else. It also handles methods, like this:

static int Foo()
{
    return 10;
}
...
Console.WriteLine(Foo());

It's got no Intellisense etc, but it may be good enough for you:)

Not in Visual Studio, but check out "STFU and Code" http://www.stfuandcode.net/

It let's you compile small apps for testing. Although you'll have to make sure you bring along all the supporting code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM