4
I am developing a C# application for Unity 3D where it will manage several types of database (Mysql, Postgress...), the problem is that I have classes that manipulate each type of database within my namespace, which are used by several other classes, the problem that these classes do not want to be instantiated outside my namespace, but inside wanted it to be free use. In java, it was enough to say that it was protected that everything was fine, but that’s not quite how it works from C#. Example in Java:
namespace MDC {
protected class Mysql {
public Mysql(){}
}
public class Database {
public Database(){
new Mysql(); // Sucesso
}
}
}
public class MainClass {
public static void Main (string[] args) {
new Database(); // Sucesso
new Mysql(); // Erro
}
}
Error happens because the Mainclass is not in the namespace MDC.
– João Sobral
The error is what I want to occur in C#, but this does not occur because there is no way I declare a Class as protected.
– Pedro Soares