Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Datarow Array with foreach question

Datarow Array with foreach question

Scheduled Pinned Locked Moved C#
helpquestiondata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Osrald
    wrote on last edited by
    #1

    Hi! newbie here just asking which of the following code is more efficient 1. DataRow[] dataRowArray = dtDataTable.Select("TableColumn = 1"); foreach(DataRow drRow in dataRowArray) { ...some processing here } OR 2. foreach(DataRow drRow in dtDataTable.Select("TableColumn = 1")) { ...some processing here } my problem here is do I need to put the result in a datarow array to make it more efficient? or not an issue at all?

    V 1 Reply Last reply
    0
    • O Osrald

      Hi! newbie here just asking which of the following code is more efficient 1. DataRow[] dataRowArray = dtDataTable.Select("TableColumn = 1"); foreach(DataRow drRow in dataRowArray) { ...some processing here } OR 2. foreach(DataRow drRow in dtDataTable.Select("TableColumn = 1")) { ...some processing here } my problem here is do I need to put the result in a datarow array to make it more efficient? or not an issue at all?

      V Offline
      V Offline
      Venk259
      wrote on last edited by
      #2

      Both the statement will give same efficiency. If you have a scenario where you want the result object of dtDataTable.Select("TableColumn = 1") , then go for the first statement. otherwise go for the second.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups