开发者

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

开发者 https://www.devze.com 2023-03-20 05:41 出处:网络
Is there any Visual Studio t开发者_JAVA技巧ool 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?

Is there any Visual Studio t开发者_JAVA技巧ool 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消