10000days
10000days

Reputation: 13

How to organize C# code in different files without GUI?

I'm beginner to C# and have to develop some C# code under linux. Until now, I could work it all out in a single file, just by using the two commands mcs and mono, without any GUI. And if possible, I'd like to avoid the GUI.

But now I want to seperate code in different files or even folders, but I could not find any explanation online.

Let's say I have some code like this

public class SpecialVector
{
// some code 
}

in some special.cs file. How can I use SpecialVector in some other file, let's say normal.cs? (Btw how do you call code grouped in a file in C#?)

Excuse me if this question has already been asked, but I don't know how to twist it so that the search engine understands my problem...

Upvotes: 0

Views: 137

Answers (1)

Visual Vincent
Visual Vincent

Reputation: 18320

As has been mentioned in the comments, if you aren't limited to Mono for a particular reason, you are highly encouraged to switch to .NET Core (now called .NET as of version 5). It has native support for both Windows, Mac and Linux, and comes with command line tools that allow you to create and build entire multi-file projects in a single command, without having to specify each individual file manually.

That being said, if you continue using Mono, you can specify multiple files to the compiler in the following manner:

mcs File1.cs File2.cs

(and so on)

Have a look at the man page for mcs for more info.

Upvotes: 1

Related Questions