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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:34:45+00:00 2026-05-16T02:34:45+00:00

What should be more appropriate to use when you want to initialize class properties

  • 0

What should be more appropriate to use when you want to initialize class properties from datatable.

i.e.

name=dt.Rows[0][0] or name=dt.Rows[0]["Name"]

Which approach is more scalable any easy to handle.
Currently I uses 2nd approach but feels like if I use indexes rather than name that i only need to change stored procedures rather that UI also.

But compromises readability of code. So What should I go for

  • 1 1 Answer
  • 1 View
  • 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-16T02:34:46+00:00Added an answer on May 16, 2026 at 2:34 am

    One option is to have something in between:

    private const int NameColumn = 0;
    ...
    name = dt.Rows[0][NameColumn];
    

    That gives you one place to change if the column ordering/definitions change, but also gives readable code at the point of access. I’m not sure it addresses the issue of having to change both the UI code and the stored procedures at the same time: if your SPs are effectively changing their public interface, you should expect to change the UI code. However, this approach can reduce the pain of that change, as well as not littering your code with magic values.

    (You might also want to consider strongly typed datasets… or moving to a non-DataTable data solution such as the Entity Framework. It may not be appropriate in your situation, but it’s worth considering.)

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

Sidebar

Related Questions

If I have a class hierarchy in which subclasses require use of more specific
It should be simple: Hook a MODEL_save_after event (or MODEL_save_before if that’s more appropriate).
Possible Duplicate: In what areas might the use of F# be more appropriate than
This is in the context of a Dojo editor, but it should apply more
http://jsperf.com/testing-foreach-vs-for-loop It was my understanding that Test Case 2 should run more slowly than
i have: \£\d+\.\d\d should find: £6.95 £16.95 etc + is one or more \.
Any suggestions on whether fewer check constraints are better, or more? How should they
If I want to use a decimal literal in code, I have seen that
I must have misunderstood something. I simply want to use performSelector: to call one
EDIT: This is not a problem with the jQuery creating the appropriate markup from

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.