Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3433644
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:36:05+00:00 2026-05-18T07:36:05+00:00

I have created a class (ConflictingBooking) that contains fields for various information in regards

  • 0
  1. I have created a class (ConflictingBooking) that contains fields for various information in regards to a specific reservation.
  2. I loop through a database and select certain reservations based on certain criteria.
  3. I want to create an instance of the class with that selected certain criteria.
  4. I then want to add each of those class instances to a List which I will use elsewhere.

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:

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

              conflictingBookings.Add(found);

In the above code, I need to replace ‘found’ programatically.

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.

Seems I have not been entirely clear – here is the appropriate 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 < 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 > 0)
            {
              int next = conflictingBookings.Count + 1;


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

              // conflictingBookings is a List<conflictingBooking>
              conflictingBookings.Add(found);
            }
          }
        }
      }

Hope that clarifies my problem.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T07:36:06+00:00Added an answer on May 18, 2026 at 7:36 am

    I think all you are looking for is to put your code in a for loop. I might be completely misunderstanding you but it seems as if you want to do something like this

    int i = 0;
    foreach(var result in resultSet)
    { 
        ConflictingBooking found = new ConflictingBooking();
        found.BookingNumber = conflictingBookingNumber;
        found.BookingStarts = conflictingBookingDT;
        found.Name = "found["+i++ +"]";
    
        conflictingBookings.Add(found);
    }
    

    If that’s not what you want please clarify your question

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a class for a dashboard item which will hold information such
I have created a class that will manage connection and commands, I named it
I have created one class that directly map to ConfigSection of web. config. My
I have created a class of type BaseAdapter that is populated with buttons -
I have created a class library (assembly) that provides messaging, email and sms. This
I have created a class that returns a datatable, when I use the class
I have created a class that extends JLabel to use as my object moving
I have created a class Atom that extends the Qt class QGraphicsItem like this:
I have created a class Car that derives form the abstract class TransportMeans and
I have created a class in which I have set some of it's fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.