Reputation: 35
Main form code:
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WFA_KONSPEKT_02
{
public partial class ET_Main : Form
{
public ET_Main(string permissions) //The program has an authenticator which uses "Permissions"
{
InitializeComponent();
Status.Text = permissions;
}
}
}
Program.cs Code:
Using System.Windows.Forms;
namespace WFA_KONSPEKT_02
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
form1 = new ET_Main();
Application.Run(form1);
}
private static Form1 form1;
public static Form1 MainForm
{
get { return form1; }
}
}
}
The error is at " form1 = new ET_Main(); " in program.cs and it says: "There is no argument given that corresponds to the required formal parameter 'permissions' of 'ET_Main.ET_Main(string)'"
I've gone through all of the formal "no argument given"-post's to no luck, I just can't seem to find any fix.
Upvotes: 0
Views: 2385
Reputation: 2110
Your public ET_Main(string permissions)
constructor requires a parameter called permissions
, that is a string
. That's why you can't call it without the parameter form1 = new ET_Main();
.
You either have to create another constructor that doesn't require the parameter, give it a default value like Joji did in the other answer, or pass the string when calling the method.
form1 = new ET_Main("some permissions");
Upvotes: 1
Reputation: 1808
replace the code with below one
public ET_Main(string permissions="") //The program has an authenticator which uses "Permissions"
{
InitializeComponent();
Status.Text = permissions;
}
Upvotes: 1