Pergunta

Hy,

I have the following constructor

public PlayMe(**int rows, int cols, string name**)
    {
        **this.rows = rows;
        this.cols = cols;
        this.Name = name;**

.............................. whith the following event handler:

        **Load += PlayMe_Load<int>(rows, cols);**


        InitializeComponent();
    }

and the method PlayMe_Load ( error I get before compiling: the non generic method PlayMe cannot be used whith type arguments ...)

 void PlayMe_Load(int rows, int cols)
        {
            // set up the form components;

            MaximizeBox = false;
            AutoSize = true;
            FormBorderStyle = FormBorderStyle.Fixed3D;
            BackColor = Color.FromArgb(30, 164, 6);
            Font = defaultFont;
            **createBoard(rows, cols);**

How I manage to send arguments between constructor , event handler and method. I am referring at rows and cols variable, but I can use also name variabile also.

Sincerly,

Foi útil?

Solução

I see the rows and cols are stored in the private fields (this.rows, this.cols), read them in the method just the same (this.rows, this.cols) instead of trying to pass as parameters (don't add static specifier to the method).

When setting an event handler you can specify only the name of the method.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top