title: Cast List<object> to List<string>
body: <p>I've spent way to much time on trying to resolve this and I don't understand why I can't cast this. I'm executing a query and pulling all the values from a specific column that is then stored in a List since it could be an int, string, or bool. The issue is during casting, I would like a dynamic solution that can validate the object type and cast accordingly.</p>
  
  <pre><code>//This handles the db connection and makes calls DbItems class
      public List&lt;object&gt; GetDBColumns(string sqlQuery, string column)
              {
                  using (SqlConnection connection = new SqlConnection(connectionString))
                  {
                      connection.Open();
                      var reader = new SqlCommand(sqlQuery, connection).ExecuteReader();
                      var values = DbItems.GetColumns(reader, column);
                      connection.Close();
                      return values;
                  }
              }
  
  Public class DbItems
  {
  
   DbItems(SqlDataReader reader, string column)
      {   //GetInt32 won't be able to handle other types of course, what could I use?
          columnData.Add(reader.GetInt32(reader.GetOrdinal(column)));
      }
  
      List&lt;object&gt; columnData = new List&lt;object&gt;();
  
      //I'm calling this static method that invokes the constructor 
      public static List&lt;object&gt; GetColumns(SqlDataReader reader, string column)
          {
              List&lt;object&gt; dataSet = new List&lt;object&gt;();
              while (reader.Read())
              {
                  dataSet.Add(new DbItem(reader, column).columnData);
              }
              return dataSet;
          }
      }
  </code></pre>
  
  <p>This works without issue, but then I'll get an int value that I'd like to cast a string and I've used Cast&lt;>, (string)columnData[0], and a couple other suggestions online and nothing works. Please assist.</p>