C#运行文本框脚本 [英] C# running textbox script

查看:65
本文介绍了C#运行文本框脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我对C#非常擅长,我想知道是否可以从文本框中运行一个外国编程语言,例如:Lua。

正是我的想法

如果我把:

print(Hello World)

我有一个自定义输出框,输出将是:

Hello World

任何人都知道如何实现这一目标吗?



我尝试过的:



我手动尝试过。

我用自定义输出尝试过它。

Hey, I'm fairly adept with C#, and I'm wondering if it would be possible to run a foreign programming language from a textbox, example: Lua.
Heres exactly what im thinking
if I put:
print("Hello World")
I have a custom output box, The output would be:
Hello World
Anyone have an idea on how i would make this happen?

What I have tried:

I've tried it manually.
I've tried it with custom output.

推荐答案

是的。您可以。这就是许多在线编译器所做的事情。



您可以考虑采用以下方法 -

1.在服务器中安装编译器(那些外语)

2.通过文本框接受用户提供的代码或程序

3.处理一段代码以查看它是否是完整的程序。如果没有,请添加必要的部分以使其成为一个完整的程序。

4.进行所有类型的验证并在失败时恢复正确的错误消息

5.如果程序看起来很好,将其写入具有所需扩展名的文件,如.c,.cpp,.cs等。

6.使用相应的编译器编译程序文件(尝试命令行编译)'



我没有尝试这样做,但这种方法应该有效。一旦你尝试这个并且面临任何问题,请告诉我。



谢谢
Yes. You can. That's what many online compilers do.

You may consider following approach to do this-
1. Install the compilers in the server (those foreign languages)
2. Accept the piece of code or the program from user via your textbox
3. Process the piece of code to see if it's a complete program or not. If not, add the necessary pieces to make it a complete program.
4. Do all kind of validation and on failure revert with correct error message
5. If the program looks good, write it in to a file with required extesion such as .c, .cpp, .cs etc.
6. Compile the program file using respective compiler (try command line compiling)'

I haven't tried doing this but this approach should work. Please let me know once you try this and if facing any issue.

Thanks


这篇关于C#运行文本框脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆