title: Assign values to 2d array and getting the output
body: <p>I am working on a Windows Forms Application and am using C#, entity framework. i have two tables in database tracks and defended points.</p>
  <p>i am trying use foreach to loop those two tables and do some equations and assign the output of the equations(_DATIX) to 2d array
  . Here is the  NOT WORKING code I tried :</p>
  <pre><code>double[,] arr = new double[db.track_776.Count(), db.defendedpoints.Count()];
  
  foreach (var track in db.track_776.ToList())
  {
      foreach (var defendedPoint in db.defendedpoints.ToList())
      {
  
          DELATX = ((double)defendedPoint.Long - (double)track.TRK_LongX) * 30.8;
          DELATY = ((double)defendedPoint.Lat - (double)track.TRK_LatY) * 27;
  
          D = (int)Math.Sqrt((DELATX * DELATX) + (DELATY * DELATY));
          double x = (double)track.XVelocity;
          double y = (double)track.YVelocity;
          S = (int)Math.Sqrt((x * x) + (y * y));
  
          _DATIX = CalculateDefendedAreaThreatIndex((int)track.Alt,
              (int)defendedPoint.DpAlt,
              (int)defendedPoint.Priority, (int)defendedPoint.Range, DELATX, DELATY, D, S, x, y);
  
          arr[db.track_776.Count(), db.defendedpoints.Count()] = _DATIX;
  </code></pre>
  <p>the output is 0 for all DATIX .(0 IS the initial Value for DATIX)</p>