title: How do I convert int to a double?
body: <p>I am having trouble converting my int values to doubles. I know I have to cast them, and I am trying to do that; but C# still gives  me an error for converting int to double and says I need a cast. Also It gives me an error for trying to obtain the value for totalunits under values. it says: "<strong>**<em>A local variable named 'values'cannot be declared in this scope because it would give a different meaning to 'values', which is already used in a parent or current scope to denote some else.</em></strong> Im confused on this error because I want totalunits to change values as well. Can somweone help me? Thank you.</p>
  
  <p>Justin</p>
  
  <p>Here is some of my code:</p>
  
  <pre><code>//Get the Refurb_Rate for the day
  
  
  private double GetRefurbRate()
  {
      string sql = "";
      double Refurb_Rate = 0;
      int totalRefurb = 0;
      int totalUnits = 0;
      string error_msg = "";
  
          //Getting the value for sql for totalRefurb
          sql = "SELECT COUNT(distinct rp.repair_ord) " +
             "FROM " + schema + ".repair_part rp " +
             "WHERE rp.repair_type = 'REFURB' and rp.created_date &gt; '" + DateTime.Now.ToString("d-MMM-yyyy") + "' ";
  
  
          while (true)
          {
              if (!myDb.RunSql(sql, true))
              {
                  error_msg = "DBError for getting Refurb Rate";
                  break;
              }
              if (myDb.dbRdr.HasRows)
              {
                  if (myDb.dbRdr.Read())
                  {
  
  
                      object[] values = new object[myDb.dbRdr.FieldCount];
                      myDb.dbRdr.GetValues(values);
                      Console.WriteLine(values[0].ToString());
                      totalRefurb = Convert.ToDouble(values[0].ToString());());// This is where convert to double error comes in.
  
  
                      //Getting the value from sql for totalUnits
                      sql = "SELECT count(distinct rp.repair_ord) " +
                          "FROM " + schema + ".repair_part rp " +
                          "WHERE rp.repair_type = 'REFURB' and rp.ref_desig is null  and rp.created_date &gt; '" + DateTime.Now.ToString("d-MMM-yyyy") + "' ";
  
                      while (true)
                      {
                          if (!myDb.RunSql(sql, true))
                          {
                              error_msg = "DBError for getting Refurb Rate";
                              break;
                          }
                          if (myDb.dbRdr.HasRows)
                          {
                              if (myDb.dbRdr.Read())
                              {
  
                                  // This is where the values error comes in
                                  object[] values = new object[myDb.dbRdr.FieldCount];
                                  myDb.dbRdr.GetValues(values);
                                  Console.WriteLine(values[1].ToString());
                                  totalUnits = Convert.ToDouble(values[1].ToString());// This is where convert to double error comes in.
  
                                  try
                                  {
  
                                      //Formula for Refurb Rate
                                      Refurb_Rate = totalRefurb / totalUnits * 100;
  
  
                                  }
                                  catch (Exception e)
                                  {
                                      Console.WriteLine(e);
                                  }
  
                              }
  
                          }
  
                          break;
                      }
                      myDb.dbRdr.Close();
  
                      if (error_msg != String.Empty)
                      {
                          MessageBox.Show(error_msg, "Get Refurb Rate",
                                          MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                      }
  
                      return Refurb_Rate;
                  }
              }
          }
      }
  </code></pre>