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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:16:42+00:00 2026-05-20T09:16:42+00:00

I have a class that performs some operations on a set of data. The

  • 0

I have a class that performs some operations on a set of data. The set of data to be processed is derived from a SQL query and usually consists of a few rows with 5 to 10 fields in the row. An example would be ..

"Bob", "Smith", "57", "555-555-5555", "Nursing"
"Pam", "Watson", "32", "555-555-3494", "Pre-Law"
"Sam", "Johnson", "42", "555-555-9382", "History"
"Paul", "Jenkins", "40", "555-555-3720", "Geography"

What is the best method to pass this data into a class? Or for that matter how about a method?

I want to make the class as generic as possible so I want to pass the data into it rather than have the class perform the data access necessary to get the data. Within the class I will need to be able to iterate through the data in order to perform some operation on it

I was initially thinking of passing in a dictionary object or a multi-dimensional array. I am looking to build the application in .NET. Thanks a bunch.

  • 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. Editorial Team
    Editorial Team
    2026-05-20T09:16:42+00:00Added an answer on May 20, 2026 at 9:16 am

    First, you should create a class to represent each row of the data; in this case Student looks like a good fit:

    class Student
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
        public string Telephone { get; set; }
        public string Major { get; set; }
    }
    

    You should create and initialize one Student class for each row of data. You can then add them to a collection class. A HashSet<Student> might be an appropriate choice:

    ISet<Student> students = new HashSet<Student>();
    for each row in query result  // (pseudocode)
    { 
        students.Add(new Student { FirstName = queryResult[0], 
                            LastName = queryResult[1] }); // other fields omitted
    }
    

    I haven’t gone into exact detail because I’m not sure how you are accessing the database.

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

Sidebar

Related Questions

I have a class BigStructure that builds a complicated data structure from some input.
I have a generic class with a non generic static method that performs some
I have a class that I need to perform some actions on but I
lets say i have a background worker in a class that perform db query
I have a class that I instantiate to save or load xml data. For
I have a data structure in my C++ program that has some attributes of
For instance... if i have a method that performs some asynchronous operation and i
I have a system that performs operations on lots of Things , these can
I have problem implementing the operator!= in a set class deriving from an abstact
I was about to build my own IEnumerable class that performs some action on

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.