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 183111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:03:29+00:00 2026-05-11T15:03:29+00:00

Say I want to loop through a datareader and create a load of objects

  • 0

Say I want to loop through a datareader and create a load of objects of a certain type but using a value from the datareader as the object name e.g.

String 'string_' + <value from datareader> = new String(); 

So if I had values temp1,temp2 & temp3 coming out of the datareader I would have 3 new objects of type string e.g.

string_temp1 string_temp2 string_temp3 

How can I create the objects with the name from the datareader?, or is there any suggestions on a better way to do this?

  • 1 1 Answer
  • 0 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. 2026-05-11T15:03:30+00:00Added an answer on May 11, 2026 at 3:03 pm

    Rather than using reflection, I think it’d be easier to just use a Dictionary that maps the names you want the objects to have to their values:

    var map = new Dictionary<String, String>(); map[...] = new String(); //   ^ //   | //   +---- substitute with whatever naming scheme you deem suitable 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say i want to loop through XML nodes but i want to ignore the
Let's say I have 2 lists in Python and I want to loop through
Here are the inputs I want to loop through Main photo: <input type=file name=image[]
say I want to scaffold generate university but university should eventually be related to
Say I want to create a sort of Pre-processor for existing java code, so
Say I want to copy all elements of list A into list B. But
I want to be able to create and unknown number of objects. I'm not
This is what im using to loop through an array of arrays. $csvpre =
I want to loop through a vector to find records with a given ID.
I need to loop through all the matches in say the following string: <a

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.