6
I’m doing my first console program in C#, just to do some tests.
I have two classes: HelloConsole.MainClass and HelloConsole.Calc.
I have the following code:
using System;
// Aprendendo o alias de namespace
using C = System.Console;
namespace HelloConsole
{
class MainClass
{
public static void Main (string[] args)
{
Calc calc = new Calc (3);
/**
* Agora já sei que WriteLine aceita múltiplos parâmetros
* Tipo o Python
* */
C.WriteLine ("O valor é {0}", calc.value);
C.WriteLine ("Soma de {0}", calc.sum (3));
C.WriteLine ("Multiplo de 3 é {0}", calc.mul(3));
Calc calc_2 = new Calc (1, 2, 3, 4, 5);
C.WriteLine("Valores da instância diferente {0}", calc_2.value);
C.WriteLine ("Valores de multiplicação é {0}", calc_2.mul(5));
}
}
}
This program works perfectly. And I understood that everything that is put within the static method Main runs on the console. I still don’t understand where the compiler "knows" is MainClass which is the main class.
This is set somewhere, or the C# Compiler understands that it is the main class because of the name MainClass?
It is possible to define another main class?
It is possible to have more than one main class?
Note: I am using Linux and compiling by Monodevelop.

