Precompiled or runtime eval?
-
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.
-
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.
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; }
-
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; }
Great thanks.