Note that there are some explanatory texts on larger screens.

plurals
  1. POC# "Object reference not set to an instance of an object."
    text
    copied!<p>I get that error when I attempt to use the btn connected to it:</p> <pre><code>private void btnAccel_Click(object sender, EventArgs e) { pStatus.Text = plane.speed.ToString(); plane.speed = double.Parse(txtSpeed.Text); plane.Accelerate(); pStatus.Text = plane.speed.ToString(); } </code></pre> <p>pStatus is a panel I use and update the current speed before and after I increase the speed. <code>plane</code> is defined above as :</p> <pre><code>Airplane plane = new Airplane(); </code></pre> <p>The error seems to happen when it gets to <code>plane.Accelerate();</code></p> <pre><code>public void Accelerate() { // increase the speed of the airplane if (PlanePosition.speed &lt; Position.MAX_SPEED) { PlanePosition.speed = PlanePosition.speed + 1; // or speed += 1; }//end of if numberCreated++; // increment the numberCreated each time an Airplane object is created }//end of public Accelerate() </code></pre> <p>That first line <code>if(PlanePosition.speed &lt; Position.MAX_SPEED)</code> is where it keeps happening from what VS is telling me.</p> <hr> <pre><code>//private variables private string name{get; set;} private Position planePosition; private static int numberCreated; //default constructor public Airplane() { }//end of public Airplane public Position PlanePosition{get;set;} class Position { //private variables internal int x_coordinate; internal int y_coordinate; internal double speed; internal int direction; internal const int MAX_SPEED = 50; //default constructor public Position() { }//end of public Position public string displayPosition() { return "okay"; }//end of public string displayPosition() }//end of class Position </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload