How can i resolve this error?C# : <p>i have a private method is ball.cs class in witch i want to modify a bool type from margins.cs class, but i get the Error   An object reference is required for the non-static field, method, or property 'PingPong.Margins.win'.
Can someone help me with this?</p>

<p>this is the ball class code :</p>

<pre><code>namespace PingPong
{
 public class Ball
{

     private PictureBox ball;
     Random rand= new Random();
     Player leftSidePlayer, rightSidePlayer;

     int xSpeed, ySpeed;

     public Ball(PictureBox aBall, Player leftSidePlayer, Player rightSidePlayer)
     {   

         this.ball = aBall;
         this.leftSidePlayer = leftSidePlayer;
         this.rightSidePlayer = rightSidePlayer;
         xSpeed = 1;
         ySpeed = 2;
         resetBall();
     } 

     internal void processmove()
     {
         var bottom = Margins.bottomOfWorld - ball.Height;
         DoMove();

         if(ball.Location.Y &gt;= bottom || ball.Location.Y &lt;= Margins.topOfWorld)
         {
             ySpeed *= -1;
         }

         if (ball.Location.X &lt;= Margins.leftOfWorld)
         {
            Score(leftSidePlayer);
         }
         else if (ball.Location.X &gt;= Margins.rightOfWorld - ball.Width) 
         {
             Score(rightSidePlayer); 
         }

         if ((leftSidePlayer.paddle.Bounds.IntersectsWith(ball.Bounds)) || (rightSidePlayer.paddle.Bounds.IntersectsWith(ball.Bounds)))
         {
             xSpeed *= -1;
             if ((ySpeed &lt;= 6 &amp;&amp; ySpeed &gt;=-6) &amp;&amp; (xSpeed &lt;= 5 &amp;&amp; xSpeed &gt;=-5) )
             {
                 if(ySpeed &lt; 0)
                 {
                     ySpeed -= 1;
                 }else
                 {
                     ySpeed += 1;
                 } 

                 if (xSpeed &lt; 0)
                 {
                     xSpeed -= 1;

                 }
                 else
                 {
                     xSpeed += 1;
                 }
             }
         }


     }

     private int DoMove()
     {
         var bottom = Margins.bottomOfWorld - ball.Height;
         ball.Location = new Point(ball.Location.X + xSpeed, Math.Max(Margins.topOfWorld, Math.Min(bottom, ball.Location.Y + ySpeed)));
         return bottom;
     }

     private void Score(Player winningPlayer)
     {
         winningPlayer.scoreNumber++;

         if(winningPlayer.scoreNumber == 7)
         {
             if(winningPlayer == leftSidePlayer  )
             {
                 Margins.win = true;
             }else if(winningPlayer == rightSidePlayer)
             {
                 Margins.win = false;
             }


         }


         resetBall();
     }

     private void resetBall()
     {
         ball.Location = new Point((Margins.leftOfWorld + Margins.rightOfWorld) / 2, (Margins.bottomOfWorld + Margins.topOfWorld) / 2);
         do
         {
             xSpeed = rand.Next(-3, 3);
             ySpeed = rand.Next(-3, 3);
         } while(Math.Abs(xSpeed) + Math.Abs(ySpeed) &lt;= 3);

    }

}
</code></pre>

<p>}</p>

<p>and this is the margins class code :</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PingPong
{
    public class Margins
    {   //Marimea ferestrei 1000; 600
        public const int topOfWorld = 0, bottomOfWorld = 560, leftOfWorld =0, rightOfWorld = 1000;
        public bool? win = null;
    }
}
</code></pre>

<p>the error i get is in private void score when i use the margins.win = true
and margins.win = false .</p>
