问题
Does anyone know if there is a c# Console app, similar to the Python or Ruby console? I know the whole "Compiled versus Interpreted" difference, but with C#'s reflection power I think it could be done.
UPDATE Well, it only took about 200 lines, but I wrote a simple one...It works a lot like osql. You enter commands and then run them with go.
SharpConsole http://www.gfilter.net/junk/sharpconsole.jpg
If anyone wants it, let me know.
回答1:
Given your mention of "C#'s reflection power", I am unsure whether you're looking for an interactive C# console for small code snippets of your own (à la Ruby's irb
), or a means of interacting with an existing, compiled application currently running as a process.
In the former case:
- Windows PowerShell might be your friend
- Another candidate would be the C# shell
- Finally, CSI, a Simple C# Interpreter
回答2:
Found this on reddit: http://tirania.org/blog/archive/2008/Sep-08.html
Quote from the site:
The idea was simple: create an interactive C# shell by altering the compiler to generate and execute code dynamically as opposed to merely generating static code.
回答3:
If you don't have to use the console, and just want a place to test some ad hoc C# snippets, then LinqPad is a good option. I find it very cool/easy to use.
回答4:
I am not sure what you are looking for this application to accomplish. If it is just to try some code without having to create a project and all the overhead to just test an idea, then SnippetCompiler could be a good fit.
I just wanted to give you another option.
回答5:
It appears Miguel De Icaza was stalking me:
http://tirania.org/blog/archive/2008/Sep-08.html
回答6:
Google reveals a few efforts at this. One in particular illustrates why this is less straightforward than it might seem. http://www.codeproject.com/KB/cs/csi.aspx has a basic interpreter using .NET's built in ability to compile c# code. A key problem is that the author's approach creates a new mini .NET assembly for each interpreted line. C# may have the reflective power to have a python or ruby style console, but the .NET framework libraries are geared toward compiling C#, not dynamically interpreting it. If you are serious about this, you may want to look at http://www.paxscript.net/, which seems like a genuine attempt at interpreted C#.
回答7:
I believe you are looking for Snippy =)
来源:https://stackoverflow.com/questions/47537/c-sharp-console