LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-24-2019, 10:26 AM   #1
slcklnx
Member
 
Registered: Jan 2019
Posts: 144

Rep: Reputation: Disabled
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.

Last edited by slcklnx; 09-24-2019 at 10:28 AM.
 
Old 09-24-2019, 10:36 AM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by slcklnx View Post
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?
 
1 members found this post helpful.
Old 09-24-2019, 01:12 PM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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.
 
1 members found this post helpful.
Old 09-24-2019, 04:19 PM   #4
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by jsbjsb001 View Post
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).
 
1 members found this post helpful.
Old 09-24-2019, 04:34 PM   #5
tofino_surfer
Member
 
Registered: Aug 2007
Posts: 483

Rep: Reputation: 153Reputation: 153
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.

Last edited by tofino_surfer; 09-25-2019 at 02:18 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration