I'm doing my first console program in C #, just to do some testing.
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 inside the static method Main
is executed on the console. But I still do not understand where the compiler "knows" which is MainClass
which is the main class.
Is this defined somewhere, or does the C # compiler understand that it is the main class because of the name MainClass
?
Is it possible to define another main class?
Is it possible to have more than one main class?
Note : I'm using Linux and compiling for Monodevelop.