| re: Optimizer Query
It will generate the same code, or at least one equivalent.
If what you are worried about is that each time the loop is executed a new
instance is created fear not, it does not happen, the variable n is created
in the stack and is created only once,
Hope this help,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Learner" <csharp@learner.here> wrote in message
news:mtpv101nri61t41v6djej5s8e1u9ko7n8q@4ax.com...[color=blue]
> With code like this:
>
> public void SomeMethod()
> {
> for (int i = 0; i < SomeLargeNumber; ++i) {
> int n = GetANumber();
> DoSomethingWith(n);
> }
> }
>
> Would the "int n" part be optimized out somewhere along the line?
> i.e.: would something like the following happen instead:
>
> public void SomeMethod()
> {
> int n;
>
> for (int i = 0; i < SomeLargeNubmer; ++i) {
> n = GetANumber();
> DoSomethingWith(n);
> }
> }
>
> Just curious...[/color] |