Home c# CS1061 error in the project

CS1061 error in the project

Author

Date

Category

But I just recently began to learn C #. According to practice in the technical school you need to make ping pong. I want in order to achieve a certain number of points, the other forms in which it was written, which player won. But I can not transfer data from Form1 variables to WPFresult (this is Form2).
Outputs: CS1061 “Form” error does not contain “W1” definitions, and it was not possible to find the available “W1” extension method, receiving the “Form” type as the first argument (possibly skipped the touch directive or the link to the assembly) what googled why It does not work.

Form1

using system;
 using System.Windows.Forms;
 Namespace Pingpong.
{
Public Partial Class Form1: Form
{
  INT SPEEDX;
  INT SPEEDY;
  int w1;
  int w2;
  Public Form1 ()
  {
    Initializecomponent ();
    SPEEDX = 4;
    Speedy = 4;
  }
  Private Void Form1_Keydown (Object Sender, Keyeventargs E)
  {
    int x = pong1.left;
    if (E.Keycode == Keys.d)
    {
      pong1.left + = 20;
    }
    if (E.Keycode == Keys.A)
    {
      pong1.left + = -20;
    }
    If (E.Keycode == Keys.Right)
    {
      pong2.left + = 20;
    }
    if (E.Keycode == Keys.left)
    {
      pong2.left + = -20;
    }
    IF (X & LT; 0)
    {
      pong1.left = 0;
    }
    IF (X & GT; 470)
    {
      pong1.left = 469;
    }
    int x1 = pong2.left;
    if (x1 & lt; 0)
    {
      pong2.left = 0;
    }
    if (x1 & gt; 470)
    {
      pong2.left = 469;
    }
  }
  Private Void Timer1_Tick (Object Sender, Eventargs E)
  {
    pong3.left = pong3.left + Speedx;
    pong3.top = pong3.top + speedy;
    if (pong3.top & lt; = 0)
    {
      Speedy = -speedy;
    }
    if (pong3.left & lt; = 0)
    {
      Speedx = -speedx;
    }
    if (pong3.left & gt; = 530)
    {
      Speedx = -speedx;
    }
    if (pong3.top & gt; = 465)
    {
      Speedy = -speedy;
    }
    if ((pong3.left + pong3.width & gt; = pong1.left) & amp; (pong3.left & lt; = pong1.left + pong1.width) & amp; (pong1.top + pong1.Height & gt; = pong3.top ))
    {
      Speedy = -speedy;
    }
    if ((pong3.left + pong3.width & gt; = pong2.left) & amp; (pong3.left & lt; = pong2.left + pong2.width) & amp; (pong3.top + pong3.Height & gt; = pong2.top ))
    {
      Speedy = -speedy;
    }
    if (pong3.top & lt; 0)
    {
      label2.text = convert.tostring (convert.toint32 (label2.text) + 1);
      w2 = int.parse (label2.text);
    }
    if (pong3.top & gt; 464)
    {
      label1.text = convert.tostring (convert.toint32 (label1.text) + 1);
      w1 = int.parse (label1.text);
    }
  }
}
}

Form2

using system.windows.Forms;
Namespace Pingpong.
{
Public Partial Class WPFresult: Form
{
  Public WPFresult ()
  {
    Form Form1 = New Form1 ();
    Initializecomponent ();
    if (form1.w1)
    {
    }
  }
}
}

Answer 1, Authority 100%

I think you need to at least make a field public and initialize.

public int w1 = 0;

in the 2nd form of a typo. It should be like this:

form1 form1 = new form1 (); // Type Form1

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions