LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   c# linux (https://www.linuxquestions.org/questions/linux-newbie-8/c-linux-4175661395/)

slcklnx 09-24-2019 10:26 AM

c# linux
 
hi

help me!
Code:


>c.cs
>cls.cs
chmod 777 c.cs
chmod 777 cls.cs

nano cls
namespace A{
public class cls{

public int a;
}

}
nano c.cs

Code:


using System;
using A;
class c{
public static void Main(){

}

}

mcs c.cs
mono c.exe

I can’t connect the class. Tell me how to do it.

jsbjsb001 09-24-2019 10:36 AM

Quote:

Originally Posted by slcklnx (Post 6040155)
hi

help me!
Code:


>c.cs
>cls.cs
chmod 777 c.cs
chmod 777 cls.cs

nano cls
namespace A{
public class cls{

public int a;
}

}
nano c.cs

Code:


using System;
using A;
class c{
public static void Main(){

}

}

mcs c.cs
mono c.exe

I can’t connect the class. Tell me how to do it.

From the very little I know about C# (C Sharp), it's a Microsoft language for Windows, and the above does not look valid at all to me - it looks like you're trying to mix a bash script with C# - I don't think you can do that. The .exe extension is for a Windows executable file, which will not run under Linux unless you have Wine installed and run it through that.

Also, your post is very vague. What exactly are you trying to write?

rtmistler 09-24-2019 01:12 PM

slcklnx,

This question is very inadequate, giving little information except a plea for help.

You've posted on the LQ forums enough to realize that this level of incomplete question is not helpful. Instructing your fellow LQ members to "Tell me how to do it" is not appropriate.

Recommend you follow some of the tutorials from mono to enable you to complete your first project. They do exist for Linux environments.

ehartman 09-24-2019 04:19 PM

Quote:

Originally Posted by jsbjsb001 (Post 6040160)
The .exe extension is for a Windows executable file, which will not run under Linux unless

The "mono" in the OP's post is a .net emulator for Linux, so with a correctly built .exe he should be able to run it (as C# is the compiler for .net executables).
But I don't see him compiling the cls.cs source, so the exe seems to be incomplete, he may need something like
Code:

mcs c.cs cls.cs
(I'm just guessing, I do not know this mcs compiler).

tofino_surfer 09-24-2019 04:34 PM

Quote:

From the very little I know about C# (C Sharp), it's a Microsoft language for Windows, and the above does not look valid at all to me - it looks like you're trying to mix a bash script with C# - I don't think you can do that. The .exe extension is for a Windows executable file, which will not run under Linux unless you have Wine installed and run it through that.
They aren't running this .exe on Linux itself but under Mono which is an open source implementation of MS .NET. With the mono interpreter/VM running on Linux they can execute a .NET .exe.

https://www.mono-project.com/

With mono they can run C# programs on Linux. The only Linux bash commands are chmod to change file permissions and the text editor nano.

mcs is the Mono project C# compiler which compiles the .exe executable the same way gcc compiles a C/C++ program.

mcs c.cs compiles c.cs to produce c.exe

mono is the interpreter or VM which runs the executable the same way a Java VM runs Java bytecode in jar files.

mono c.exe attempts to run c.exe with the mono interpreter.

As ehartman said they don't seem to be compiling cls.cs.


All times are GMT -5. The time now is 03:28 AM.