title: System::Object to int or double in C++/CLI
body: <p>I'm taking some information from data base and i want to use it in calculations. But due to what i'written, i'm not able to convert it to number. I recieve <code>System::Object^</code>. here is the part of code:</p>
  
  <pre><code>OleDbConnection ^ cnNwind = gcnew OleDbConnection();
  
  cnNwind-&gt; ConnectionString = 
  L"Provider = Microsoft.Jet.OLEDB.4.0;" 
  L"Data Source = C:\\temp\\A.mdb";
  
  try
  {
      // Open the database
      cnNwind-&gt;Open();
      Console::WriteLine(L"Connected to database successfully!");
  
      // Count the customers
      OleDbCommand ^ cmProducts = gcnew OleDbCommand();
      cmProducts-&gt;CommandText = L"SELECT ID FROM Table1";
      cmProducts-&gt;CommandType = CommandType::Text;
      cmProducts-&gt;Connection = cnNwind;
  
      // Print the result
      Object ^ numberOfProducts = cmProducts-&gt;ExecuteScalar();
      Console::Write(L"Number of products: ");
      Console::WriteLine(numberOfProducts);
  }
  catch (OleDbException ^ pe)
  {
      Console::Write(L"Error occurred: ");
      Console::WriteLine(pe-&gt;Message);
  }
  // Close the connection
  if (cnNwind-&gt;State != ConnectionState::Closed)
  {
      cnNwind-&gt;Close();
  }
  
  Console::WriteLine(L"The database connection is closed...");
  </code></pre>
  
  <p>I want to use <code>numberOfProducts</code> as a digit. I mean type <code>double</code> or <code>integer</code>. How can i transform it?</p>