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. Precompiled or runtime eval?

Precompiled or runtime eval?

Scheduled Pinned Locked Moved C#
performancequestion
3 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.
  • S Offline
    S Offline
    spin vector
    wrote on last edited by
    #1

    Consider the code DataTable dt = /* something */ double h_bid = (double)dt.Row[(int)SecurityColumns.BID]; double h_offer = (double)dt.Row[(int)SecurityColumns.ASK]; where /SecurityColumns.BID/ and /.ASK/ come from the enum type /SecurityColumns/. Does the compiler determine before runtime the integer values of .BID and .ASK and make the substitution into the binaries? Or is the enum eval'd at runtime and converted to an int? Execution speed is what I'm after. Thanks.

    G 1 Reply Last reply
    0
    • S spin vector

      Consider the code DataTable dt = /* something */ double h_bid = (double)dt.Row[(int)SecurityColumns.BID]; double h_offer = (double)dt.Row[(int)SecurityColumns.ASK]; where /SecurityColumns.BID/ and /.ASK/ come from the enum type /SecurityColumns/. Does the compiler determine before runtime the integer values of .BID and .ASK and make the substitution into the binaries? Or is the enum eval'd at runtime and converted to an int? Execution speed is what I'm after. Thanks.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      As the values of the enum is known at compile time, the values will be evaluated when it's compiled. The compiler always evaluates everything that it can. For an example: string msg = "Hello" + " " + "world!"; produces the exact same code as: string msg = "Hello world!";

      --- b { font-weight: normal; }

      S 1 Reply Last reply
      0
      • G Guffa

        As the values of the enum is known at compile time, the values will be evaluated when it's compiled. The compiler always evaluates everything that it can. For an example: string msg = "Hello" + " " + "world!"; produces the exact same code as: string msg = "Hello world!";

        --- b { font-weight: normal; }

        S Offline
        S Offline
        spin vector
        wrote on last edited by
        #3

        Great thanks.

        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