title: errors: Index out of range exception unhandled and Operator '*' cannot be applied to operands of type 'object' and 'int'
body: <p>i am getting 'Index out of range exception unhandled' in my form1.i will be pointing it out by comments.i am showing you only the part of the code where i use the following declarations.</p>
  
  <p>here is my form1</p>
  
  <pre><code>    Int32 u, v;
      int32[] l = new int32[2];
      int32[] m = new int32[2];
      int32[] g = new int32[2];
      int32[] h = new int32[2];
      int TwoClicks = 0;
  
      private WindowsFormsApplication2.Form2 _form2 = new WindowsFormsApplication2.Form2();
  
      private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
      {
          if (TwoClicks &lt; 2)
          {
               TwoClicks++;
  
          DialogResult dialogresult = _form2.ShowDialog(this);
  
  
          if (dialogresult == DialogResult.OK)
          {
  
                  rect.Width = 0;
                  rect.Height = 0;
                  pictureBox1.Invalidate();
  
                  l[TwoClicks] = e.X;// I am getting the exception here
                  m[TwoClicks] = e.Y;
  
  
          }
          if (dialogresult == DialogResult.Cancel)
          {
              rect.Width = 0;
              rect.Height = 0;
              pictureBox1.Invalidate();
              TwoClicks--;
          }
  
  
          }
      }
  
  
      private void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
      {
          int radius = 10; //Set the number of pixel you want to use here
          //Calculate the numbers based on radius
          int x0 = Math.Max(e.X - (radius / 2), 0),
              y0 = Math.Max(e.Y - (radius / 2), 0),
              x1 = Math.Min(e.X + (radius / 2), pictureBox1.Width),
              y1 = Math.Min(e.Y + (radius / 2), pictureBox1.Height);
          Bitmap bm = pictureBox1.Image as Bitmap; //Get the bitmap (assuming it is stored that way)
          for (int ix = x0; ix &lt; x1; ix++)
          {
              for (int iy = y0; iy &lt; y1; iy++)
              {
                  bm.SetPixel(ix, iy, Color.Black); //Change the pixel color, maybe should be relative to bitmap
              }
          }
          pictureBox1.Refresh(); //Force refresh
  
              u = (e.X - l[0]) * (g[1] - g[0]) / (l[1] - l[0]);
              v = (e.Y - m[0]) * (h[1] - h[0]) / (m[1] - m[0]);
  
          MessageBox.Show(String.Format("latitude is {0} degrees {1} minutes and longitude is {2} degrees {3} minutes", u / 60, u % 60, v / 60, v % 60));
      }
  </code></pre>
  
  <p>I am getting this error : Operator '*' cannot be applied to operands of type 'object' and 'int' in my form2 which i use as a custom message box.
  there are also few other errors which im getting.</p>
  
  <p>--->Cannot implicitly convert type 'int' to 'WindowsFormsApplication2.int32'</p>
  
  <p>--->Operator '-' cannot be applied to operands of type 'WindowsFormsApplication2.int32' and 'WindowsFormsApplication2.int32'</p>
  
  <p>--->Operator '-' cannot be applied to operands of type 'int' and  WindowsFormsApplication2.int32'   </p>
  
  <p>Here is my Form2</p>
  
  <pre><code>    int32[] g = new int32[3];
      int32[] h = new int32[3];
      int TwoClicks = 0;
  
      private void Form2_Load(object sender, EventArgs e)
      {
  
              g[TwoClicks] = (int32.Parse(textBox1.Text) * 60 + int32.Parse(textBox2.Text));
              h[TwoClicks] = (int32.Parse(textBox3.Text) * 60 + int32.Parse(textBox4.Text));
  
      }
  </code></pre>