如何在Linux终端上执行C#代码作为Shell脚本.
How can I execute a C# code on a linux terminal as a shell script.
我有以下示例代码:
public string Check(string _IPaddress,string _Port, int _SmsID) { ClassGlobal._client = new TcpClient(_IPaddress, Convert.ToInt32(_Port)); ClassGlobal.SMSID = _SmsID; string _result = SendToCAS(_IPaddress, _Port, _SmsID ); if (_result != "") return (_result); string _acoknoledgement = GetFromCAS(); return _acoknoledgement; }当我运行shell bash时,我使用#!/bin/bash. C#有相同的用法吗?
When I run a shell bash I use #!/bin/bash. There is how to do the same with C#?
推荐答案#!(hashbang)标记用于告诉shell使用哪个解释器,以便您的perl,php,bash,sh等脚本将正确运行.
The #! (hashbang) tag is used to tell the shell which interpreter to use so that your perl, php, bash, sh, etc. scripts will run right.
但是C#不是脚本语言,它旨在被编译成可执行格式.如果要使用C#,则至少需要安装编译器和运行时,最好是IDE(集成开发环境)来帮助您开发和调试应用程序.
But C# is not a scripting language, it is intended to be compiled into an executable format. You need to install at least a compiler and runtime if you want to use C#, and preferably an IDE (Integrated Development Environment) to help you develop and debug your applications.
为编译器和运行时安装 Mono ,然后 MonoDevelop .
Install Mono for the compiler and runtime, then MonoDevelop for the IDE.
更多推荐
在Linux终端上运行C#代码
发布评论