在Linux终端上运行C#代码 [英] Run C# code on linux terminal

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

问题描述

如何在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 ,然后

Install Mono for the compiler and runtime, then MonoDevelop for the IDE.

这篇关于在Linux终端上运行C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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