I’ve a question related to some C# implementation on Model-View-Controller. I am fairly new to C#, so I would appreciate some explanations.
I am developing an Windows application. It is build as follows, with Visual Studio. It makes use of the following 3 classes. Program.cs, Controller.cs and mainWindow.cs. When the application starts I want to create a controller that creates a mainWindow and after that the controller should process all data entered in the mainWindow.
Program.cs:
static void main() {
Controller controller = new Controller();
controller.init();
}
Controller.cs
class Controller {
public void init() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mainWindow(this));
}
}
mainWindow.cs
public partial class mainWindow : Form
{
public mainWindow(Controller parent)
{
InitializeComponent();
parent.closeThisForm();
}
}
So when I try to run this code I get the following error:
Inconsistent accessibility: parameter type ‘…Controller’ is less accessible than method ‘abc.mainWindow.mainWindow(abc.Controllers.mainController)’.
I understand that is has to do something with privileges, but don’t understand exactly why and what.
Hope anyone can help me with this, (rather simple looking) problem.
I believe you need to make the Controller class public
public class Controller