Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# Adding a Method

Evan Welch
Evan Welch
1,815 Points

How do I run the Program.cs?

How do I run the Program.cs?

mcs Program.cs ... then I need to reference the other .cs files using *.cs somehow?

2 Answers

Dane Parchment
MOD
Dane Parchment
Treehouse Moderator 11,077 Points

Here is what you should be running:

mcs *.cs -out:Program.exe && mono Program.exe  

I'll break it down:

  1. mcs: The compiler that we are using, by executing this command and providing it with a file/glob/files we are able to compile the result.
  2. *.cs: A glob that says that we are going to get any file that ends in .cs basically all the C# files in our folder.
  3. -out:Program.exe: An optional command that specifies what we are going to call our output file. In this case: Program.exe. 4.&&: Tells us to chain together another additional command
  4. mono Program.exe: Mono is how we execute a C# executable, we just have to provide it with said executable. In this case the newly created Program.exe.
Evan Welch
Evan Welch
1,815 Points

Thank you Dane Parchment!

So, mcs is the name of the Treehouse's complier?

And, -out:Program.exe converts the Program.cs file to a executable file?

Then we run with mono.