c# - There is no argument given that corresponds to the require formal parameter (opening form from a form) -


i've been trying move code separate class , have changed following:

public partial class questionnaire : form {      public questionnaire()     {         initializecomponent();                 } 

to

private readonly getcomponentsql _getcomponentsql;  public questionnaire(getcomponentsql arggetcomponentsql) {     _getcomponentsql = arggetcomponentsql;      initializecomponent();             } 

form1 contains button1 opens questionnaire.

private void button1_click(object sender, eventargs e) {     questionnaire q1 = new questionnaire();     q1.showdialog(); // shows gpu_suggestion } 

regarding questionnaire q1 = newquestionnaire();

the following error message shows - there no argument given corresponds required formal parameter 'arggetcomponentsql' of 'questionnaire.questionnaire(getcomponentsql)'

i have changed button1_click to:

private void button1_click(object sender, eventargs e) {     questionnaire q1 = new questionnaire(getcomponentsql arggetcomponentsql);     q1.showdialog(); // shows gpu_suggestion } 

but following 3 error messages:

syntax error, ',' expected

'getcomponentsql' type, not valid in given context

the name 'arggetcomponentsql' not exist in current context

in line

questionnaire q1 = new questionnaire(getcomponentsql arggetcomponentsql); 

you attempting declare new variable of type getcomponentsql named arggetcomponentsql. won't work in context of passing argument constructor (or other method or function). instead must declare variable on line preceding instantiation of new questionnaire, , initialize before passing argument constructor.


Comments