Creating instances of classes at runtime
<ol>
<li>I have created a class (ConflictingBooking) that contains fields for various information in regards to a specific reservation.</li>
<li>I loop through a database and select certain reservations based on certain criteria.</li>
<li>I want to create an instance of the class with that selected certain criteria.</li>
<li>I then want to add each of those class instances to a List which I will use elsewhere.</li>
</ol>

<p>Problem I have is at step 3. I want to name the new instance something like "found[i]" where i is incremented for each reservation found:</p>

<pre><code>              ConflictingBooking found = new ConflictingBooking();
              found.BookingNumber = conflictingBookingNumber;
              found.BookingStarts = conflictingBookingDT;

              conflictingBookings.Add(found);
</code></pre>

<p>In the above code, I need to replace 'found' programatically.</p>

<p>Whilst I would appreciate a simple code snippet to follow, I would also like to read some reference so I know what I'm doing :-). I just don't know how to google my problem.</p>

<p>Seems I have not been entirely clear - here is the appropriate code:</p>

<pre><code>      dbManager.Open();
      dbManager.ExecuteReader(CommandType.Text, string.Format("SELECT BookingDate, {0} FROM BTable WHERE Court IN {1} AND BookingDate IN ({2})", columns, facilityIDs, bookingDates));
      using (IDataReader rdr = dbManager.DataReader)
      {
        decimal conflictingBookingNumber = 0;
        DateTime conflictingBookingDT;
        object result = null;
        while (rdr.Read())
        {
          for (int i = 0; i &lt; requestedColumnNames.Count; i++)
          {
            result = dbManager.DataReader[requestedColumnNames[i].ToString()];
            if (result != null)
              conflictingBookingNumber = Convert.ToDecimal(result);

            result = dbManager.DataReader["BookingDate"];
            if (result != null)
              conflictingBookingDT = Convert.ToDateTime(result);

            if (conflictingBookingNumber &gt; 0)
            {
              int next = conflictingBookings.Count + 1;


              ConflictingBooking found = new ConflictingBooking();
              found.BookingNumber = conflictingBookingNumber;
              found.BookingStarts = conflictingBookingDT;

              // conflictingBookings is a List&lt;conflictingBooking&gt;
              conflictingBookings.Add(found);
            }
          }
        }
      }
</code></pre>

<p>Hope that clarifies my problem.</p>
